summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBirte Kristina Friesel <derf@finalrewind.org>2024-05-04 10:04:54 +0200
committerBirte Kristina Friesel <derf@finalrewind.org>2024-05-04 10:04:54 +0200
commitf4c4fde673b21d248e5f472543568b72ade2105e (patch)
treef31e6dc7d4aff7cef50ff93a5a40bfad129ba0dd
parent77f36b104c86f9a59c1afb13b24f9b7446002842 (diff)
Optionally store captions and copyright in EXIF data
-rwxr-xr-xbin/pyggle45
1 files changed, 37 insertions, 8 deletions
diff --git a/bin/pyggle b/bin/pyggle
index e549584..07b778a 100755
--- a/bin/pyggle
+++ b/bin/pyggle
@@ -544,6 +544,17 @@ if __name__ == "__main__":
formatter_class=argparse.RawDescriptionHelpFormatter, description=__doc__
)
parser.add_argument(
+ "--caption-to-exif",
+ action="store_true",
+ help="Store captions as EXIF comments (IN-PLACE EDIT)",
+ )
+ parser.add_argument(
+ "--exif-copyright",
+ metavar="STRING",
+ type=str,
+ help="Set EXIF copyright (IN-PLACE EDIT)",
+ )
+ parser.add_argument(
"--html-include",
metavar="FILE",
type=str,
@@ -561,7 +572,9 @@ if __name__ == "__main__":
type=int,
help="resize large images to no more than NxN pixels (IN-PLACE EDIT)",
)
- parser.add_argument("--reverse", action="store_true", help="Reverse sort order")
+ parser.add_argument(
+ "--reverse", action="store_true", help="Sort from most to least recent"
+ )
parser.add_argument(
"--scrub-metadata",
action="store_true",
@@ -611,9 +624,10 @@ if __name__ == "__main__":
# perhaps raise a warning?
continue
- thumbnails.append(
- Thumbnail(filename, im.copy(), size=args.size, with_gps=args.with_nominatim)
+ thumbnail = Thumbnail(
+ filename, im.copy(), size=args.size, with_gps=args.with_nominatim
)
+ thumbnails.append(thumbnail)
if args.resize and (im.size[0] > args.resize or im.size[1] > args.resize):
subprocess.run(
@@ -625,21 +639,36 @@ if __name__ == "__main__":
]
)
+ exiftool_args = list()
+
+ if args.caption_to_exif and thumbnail.html.caption:
+ exiftool_args.append(f"-File:Comment={thumbnail.html.caption}")
+
+ if args.exif_copyright:
+ exiftool_args.append(f"-EXIF:Copyright={args.exif_copyright}")
+
if args.scrub_metadata:
- subprocess.run(
+ exiftool_args.extend(
[
- "exiftool",
- "-q",
- "-overwrite_original",
"-EXIF:SerialNumber=",
"-EXIF:LensSerialNumber=",
"-Makernotes:all=",
"-geotag=",
"-ThumbnailImage=",
- filename,
]
)
+ if exiftool_args:
+ subprocess.run(
+ [
+ "exiftool",
+ "-q",
+ "-overwrite_original",
+ ]
+ + exiftool_args
+ + [filename]
+ )
+
if args.sort == "time":
thumbnails = sorted(thumbnails, key=lambda t: t.exif_dt, reverse=args.reverse)