-
I have TIFF images that I read the EXIF data from and then convert those to JPEG and I'd like a way to preserve as much of the original EXIF data as possible. Currently I do it like this: src_img = Image.open(input_file)
exif = src_img.getexif()
for key, value in exif.items():
if isinstance(value, tuple):
del exif[key]
dst_img = ImageOps.exif_transpose(src_img).convert("RGB")
output_file = io.BytesIO()
dst_img.save(output_file, "jpeg", quality=95, exif=exif) I'm removing the tuple values because otherwise I get an Exception Is there a better way to do this? Or should I just not do this at all? |
Beta Was this translation helpful? Give feedback.
Answered by
radarhere
Feb 3, 2023
Replies: 1 comment 1 reply
-
Rather than deleting all of the tuple values, you should be able to just delete the STRIPOFFSETS tag. from PIL import TiffImagePlugin
del exif[TiffImagePlugin.STRIPOFFSETS] |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
gverm
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Rather than deleting all of the tuple values, you should be able to just delete the STRIPOFFSETS tag.