Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for Big Sur #31

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 35 additions & 34 deletions dogsheep_photos/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
CONTENT_TYPES,
get_all_keys,
osxphoto_to_row,
osxphoto_to_score_row,
to_uuid,
s3_upload,
hash_and_size_path,
Expand Down Expand Up @@ -205,40 +206,37 @@ def apple_photos(db_path, library, image_url_prefix, image_url_suffix):
db["apple_photos_scores"].drop()
db.conn.execute(
"""
create table apple_photos_scores as select
ZGENERICASSET.ZUUID,
ZGENERICASSET.ZOVERALLAESTHETICSCORE,
ZGENERICASSET.ZCURATIONSCORE,
ZGENERICASSET.ZPROMOTIONSCORE,
ZGENERICASSET.ZHIGHLIGHTVISIBILITYSCORE,
ZCOMPUTEDASSETATTRIBUTES.ZBEHAVIORALSCORE,
ZCOMPUTEDASSETATTRIBUTES.ZFAILURESCORE,
ZCOMPUTEDASSETATTRIBUTES.ZHARMONIOUSCOLORSCORE,
ZCOMPUTEDASSETATTRIBUTES.ZIMMERSIVENESSSCORE,
ZCOMPUTEDASSETATTRIBUTES.ZINTERACTIONSCORE,
ZCOMPUTEDASSETATTRIBUTES.ZINTERESTINGSUBJECTSCORE,
ZCOMPUTEDASSETATTRIBUTES.ZINTRUSIVEOBJECTPRESENCESCORE,
ZCOMPUTEDASSETATTRIBUTES.ZLIVELYCOLORSCORE,
ZCOMPUTEDASSETATTRIBUTES.ZLOWLIGHT,
ZCOMPUTEDASSETATTRIBUTES.ZNOISESCORE,
ZCOMPUTEDASSETATTRIBUTES.ZPLEASANTCAMERATILTSCORE,
ZCOMPUTEDASSETATTRIBUTES.ZPLEASANTCOMPOSITIONSCORE,
ZCOMPUTEDASSETATTRIBUTES.ZPLEASANTLIGHTINGSCORE,
ZCOMPUTEDASSETATTRIBUTES.ZPLEASANTPATTERNSCORE,
ZCOMPUTEDASSETATTRIBUTES.ZPLEASANTPERSPECTIVESCORE,
ZCOMPUTEDASSETATTRIBUTES.ZPLEASANTPOSTPROCESSINGSCORE,
ZCOMPUTEDASSETATTRIBUTES.ZPLEASANTREFLECTIONSSCORE,
ZCOMPUTEDASSETATTRIBUTES.ZPLEASANTSYMMETRYSCORE,
ZCOMPUTEDASSETATTRIBUTES.ZSHARPLYFOCUSEDSUBJECTSCORE,
ZCOMPUTEDASSETATTRIBUTES.ZTASTEFULLYBLURREDSCORE,
ZCOMPUTEDASSETATTRIBUTES.ZWELLCHOSENSUBJECTSCORE,
ZCOMPUTEDASSETATTRIBUTES.ZWELLFRAMEDSUBJECTSCORE,
ZCOMPUTEDASSETATTRIBUTES.ZWELLTIMEDSHOTSCORE
from
attached.ZGENERICASSET
join attached.ZCOMPUTEDASSETATTRIBUTES on
attached.ZGENERICASSET.Z_PK = attached.ZCOMPUTEDASSETATTRIBUTES.ZASSET;
"""
CREATE TABLE apple_photos_scores(
ZUUID TEXT,
ZOVERALLAESTHETICSCORE REAL,
ZCURATIONSCORE REAL,
ZPROMOTIONSCORE REAL,
ZHIGHLIGHTVISIBILITYSCORE REAL,
ZBEHAVIORALSCORE REAL,
ZFAILURESCORE REAL,
ZHARMONIOUSCOLORSCORE REAL,
ZIMMERSIVENESSSCORE REAL,
ZINTERACTIONSCORE REAL,
ZINTERESTINGSUBJECTSCORE REAL,
ZINTRUSIVEOBJECTPRESENCESCORE REAL,
ZLIVELYCOLORSCORE REAL,
ZLOWLIGHT REAL,
ZNOISESCORE REAL,
ZPLEASANTCAMERATILTSCORE REAL,
ZPLEASANTCOMPOSITIONSCORE REAL,
ZPLEASANTLIGHTINGSCORE REAL,
ZPLEASANTPATTERNSCORE REAL,
ZPLEASANTPERSPECTIVESCORE REAL,
ZPLEASANTPOSTPROCESSINGSCORE REAL,
ZPLEASANTREFLECTIONSSCORE REAL,
ZPLEASANTSYMMETRYSCORE REAL,
ZSHARPLYFOCUSEDSUBJECTSCORE REAL,
ZTASTEFULLYBLURREDSCORE REAL,
ZWELLCHOSENSUBJECTSCORE REAL,
ZWELLFRAMEDSUBJECTSCORE REAL,
ZWELLTIMEDSHOTSCORE REAL
);
"""
)
db["apple_photos_scores"].create_index(["ZUUID"])

Expand All @@ -258,6 +256,9 @@ def apple_photos(db_path, library, image_url_prefix, image_url_suffix):
db["apple_photos"].insert(
photo_row, pk="uuid", replace=True, alter=True,
)
score_row = osxphoto_to_score_row(photo)
db["apple_photos_scores"].insert(score_row, pk="ZUUID", replace=True, alter=True
)
# Ensure indexes
for column in ("date", "sha256"):
try:
Expand Down
33 changes: 33 additions & 0 deletions dogsheep_photos/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,39 @@ def osxphoto_to_row(sha256, photo):
row["place_{}".format(key)] = value
return row

def osxphoto_to_score_row(photo):
score = photo.score
return {
"ZUUID": photo.uuid,
"ZOVERALLAESTHETICSCORE": score.overall,
"ZCURATIONSCORE": score.curation,
"ZPROMOTIONSCORE": score.promotion,
"ZHIGHLIGHTVISIBILITYSCORE": score.highlight_visibility,
"ZBEHAVIORALSCORE": score.behavioral,
"ZFAILURESCORE": score.failure,
"ZHARMONIOUSCOLORSCORE": score.harmonious_color,
"ZIMMERSIVENESSSCORE": score.immersiveness,
"ZINTERACTIONSCORE": score.interaction,
"ZINTERESTINGSUBJECTSCORE": score.interesting_subject,
"ZINTRUSIVEOBJECTPRESENCESCORE": score.intrusive_object_presence,
"ZLIVELYCOLORSCORE": score.lively_color,
"ZLOWLIGHT": score.low_light,
"ZNOISESCORE": score.noise,
"ZPLEASANTCAMERATILTSCORE": score.pleasant_camera_tilt,
"ZPLEASANTCOMPOSITIONSCORE": score.pleasant_composition,
"ZPLEASANTLIGHTINGSCORE": score.pleasant_lighting,
"ZPLEASANTPATTERNSCORE": score.pleasant_pattern,
"ZPLEASANTPERSPECTIVESCORE": score.pleasant_perspective,
"ZPLEASANTPOSTPROCESSINGSCORE": score.pleasant_post_processing,
"ZPLEASANTREFLECTIONSSCORE": score.pleasant_reflection,
"ZPLEASANTSYMMETRYSCORE": score.pleasant_symmetry,
"ZSHARPLYFOCUSEDSUBJECTSCORE": score.sharply_focused_subject,
"ZTASTEFULLYBLURREDSCORE": score.tastefully_blurred,
"ZWELLCHOSENSUBJECTSCORE": score.well_chosen_subject,
"ZWELLFRAMEDSUBJECTSCORE": score.well_framed_subject,
"ZWELLTIMEDSHOTSCORE": score.well_timed_shot,
}


def to_utc_isoformat(dt):
if not dt:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def get_long_description():
install_requires=[
"sqlite-utils>=2.7",
"boto3>=1.12.41",
"osxphotos>=0.28.13 ; sys_platform=='darwin'",
"osxphotos>=0.38.6 ; sys_platform=='darwin'",
],
extras_require={"test": ["pytest"]},
tests_require=["dogsheep-photos[test]"],
Expand Down