Unverified Commit cdd6192c authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

Add support for .CR3 files

parent cc9e8249
Loading
Loading
Loading
Loading
+55 −3
Original line number Diff line number Diff line
@@ -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,9 +773,48 @@ if __name__ == "__main__":
            try:
                im = Image.open(f".thumbnail.for.{filename}")
            except FileNotFoundError:
                continue
                im = None
            except PIL.UnidentifiedImageError:
                # perhaps raise a warning?
                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: