You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Open an image, edit it's exif information, save the image and check the metadata.
What did you expect to happen?
I expected the modified exif information to be written. This is exactly what happend when saving the image as a png.
What actually happened?
The exif information was not saved when using the jpg format. It works when explicitly adding the exif parameter to the save call but this requires adding the exif information everywhere save is called (potentially third party code).
This also means that exif information contained in the original image will be removed by loading and saving a JPEG image using PIL. If this is desired the PNG plugin should probably be modified to handle exif information in the same manner as the JPEG plugin, but for my usecase I prefer the way it is handled in PNG.
What are your OS, Python and Pillow versions?
OS: Arch Linux with Kernel 6.0.6
Python: 3.10.8
Pillow: 9.4.0.dev0 (current main branch)
fromPILimportImagefromPILimportExifTagsdesc="My image description"exif_tag=ExifTags.Base.ImageDescriptionimg=Image.open("hopper.jpg")
exif=Image.Exif()
exif[exif_tag] ="My image description"img.info["exif"] =exif# png plugin does save exif informationimg.save("hopper_out.png")
png_exif=Image.open("hopper_out.png").getexif()
assertpng_exif!= {}
assertpng_exif[exif_tag] ==desc# jpeg plugin does not save exif informationimg.save("hopper_out.jpg")
jpg_exif=Image.open("hopper_out.jpg").getexif()
assertjpg_exif!= {}
assertjpg_exif[exif_tag] ==desc
The text was updated successfully, but these errors were encountered:
As you've noted in your PR #6807, JPEG, TIFF and WebP don't save the EXIF data from info by default (and incidentally, neither does MPO). Only PNG does.
If you don't have strong feelings about it, it would seem less disruptive to change PNG to match the other formats. I've created PR #6819 for this.
What did you do?
Open an image, edit it's exif information, save the image and check the metadata.
What did you expect to happen?
I expected the modified exif information to be written. This is exactly what happend when saving the image as a
png
.What actually happened?
The exif information was not saved when using the
jpg
format. It works when explicitly adding theexif
parameter to thesave
call but this requires adding the exif information everywheresave
is called (potentially third party code).This also means that exif information contained in the original image will be removed by loading and saving a JPEG image using PIL. If this is desired the PNG plugin should probably be modified to handle exif information in the same manner as the JPEG plugin, but for my usecase I prefer the way it is handled in PNG.
What are your OS, Python and Pillow versions?
The text was updated successfully, but these errors were encountered: