From c70415ede2bba12aefe326aa565ac300c7dfb2c7 Mon Sep 17 00:00:00 2001 From: rrr-marble Date: Sun, 19 Dec 2021 21:19:25 +0300 Subject: [PATCH 1/2] fix: image flips after stripping orientation exif --- util/import_photos.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/util/import_photos.py b/util/import_photos.py index 4e80210..d6d272f 100644 --- a/util/import_photos.py +++ b/util/import_photos.py @@ -32,6 +32,10 @@ def process_pictures(source: str, dest_shrunk: str, dest_original: str): (k[5:], v) for k, v in image.metadata.items() if k.startswith("exif:") ) with image.clone() as cloned: + # adjust an image so that its orientation is suitable for viewing + # (i.e. top-left orientation) by checking EXIF data + cloned.auto_orient() + # strip an image of all profiles and comments cloned.strip() # Q: may damage icc, do we allow that or use smh else? cloned.transform(resize="50%") # Q: what do we want here? # move them to the processed folder From 415b3f50a2e83bd4b5f5b5c13f3437df5fa4fb34 Mon Sep 17 00:00:00 2001 From: rrr-marble Date: Sun, 19 Dec 2021 21:22:48 +0300 Subject: [PATCH 2/2] add: resize image so shorter side<=1000px --- util/import_photos.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/util/import_photos.py b/util/import_photos.py index d6d272f..32a4065 100644 --- a/util/import_photos.py +++ b/util/import_photos.py @@ -37,7 +37,9 @@ def process_pictures(source: str, dest_shrunk: str, dest_original: str): cloned.auto_orient() # strip an image of all profiles and comments cloned.strip() # Q: may damage icc, do we allow that or use smh else? - cloned.transform(resize="50%") # Q: what do we want here? + # resize the shorter side to be no more than 1000px + # https://legacy.imagemagick.org/discourse-server/viewtopic.php?p=44329#p44329 + cloned.transform(resize="1000^>") # Q: what do we want here? # move them to the processed folder cloned.save(filename=path.join(dest_shrunk, filename))