summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorBirte Kristina Friesel <derf@finalrewind.org>2024-05-15 21:55:34 +0200
committerBirte Kristina Friesel <derf@finalrewind.org>2024-05-15 21:55:34 +0200
commitcdd6192c42241cda0f875f8ce1dd2ff1c4b31c8e (patch)
tree0b06688f7349ef5ea6a8a167644ea77b8da8c026 /bin
parentcc9e8249c77fcdbbb80ec9a18e6eb2e4d1fb4527 (diff)
Add support for .CR3 files
Diffstat (limited to 'bin')
-rwxr-xr-xbin/pyggle58
1 files changed, 55 insertions, 3 deletions
diff --git a/bin/pyggle b/bin/pyggle
index 6c6cc87..be4a028 100755
--- a/bin/pyggle
+++ b/bin/pyggle
@@ -16,6 +16,7 @@ from progress.bar import Bar
import shutil
import subprocess
import sys
+import tempfile
geocoder = None
location_cache = dict()
@@ -294,7 +295,7 @@ class Thumbnail:
im = im.convert("RGB")
im.save(self.thumbname, "JPEG")
- if filename.lower().endswith(".cr2"):
+ if filename.lower().endswith((".cr2", ".cr3")):
try:
jpegname = f".thumbnails/{thumb_filename}.p.jpg"
subprocess.run(
@@ -308,6 +309,18 @@ class Thumbnail:
filename,
]
)
+ # JpgFromRaw tends to have higher resolution, so overwrite PreviewImage if it is present
+ subprocess.run(
+ [
+ "exiftool",
+ "-quiet",
+ "-binary",
+ "-tagOut!",
+ jpegname,
+ "-JpgFromRaw",
+ filename,
+ ]
+ )
self.jpegname = jpegname
except FileNotFoundError:
pass
@@ -760,10 +773,49 @@ if __name__ == "__main__":
try:
im = Image.open(f".thumbnail.for.{filename}")
except FileNotFoundError:
- continue
+ im = None
except PIL.UnidentifiedImageError:
# perhaps raise a warning?
- continue
+ im = None
+
+ if not im:
+ try:
+ _, jpegname = tempfile.mkstemp(suffix="jpg")
+ subprocess.run(
+ [
+ "exiftool",
+ "-quiet",
+ "-binary",
+ "-tagOut!",
+ jpegname,
+ "-PreviewImage",
+ filename,
+ ]
+ )
+ # JpgFromRaw tends to have higher resolution, so overwrite PreviewImage if it is present
+ subprocess.run(
+ [
+ "exiftool",
+ "-quiet",
+ "-binary",
+ "-tagOut!",
+ jpegname,
+ "-JpgFromRaw",
+ filename,
+ ]
+ )
+
+ im = Image.open(jpegname)
+ os.remove(jpegname)
+ except FileNotFoundError:
+ im = None
+ except PIL.UnidentifiedImageError:
+ # perhaps raise a warning?
+ os.remove(jpegname)
+ im = None
+
+ if not im:
+ continue
try:
im_copy = im.copy()