Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EXIF prefix saved in WebP #6580

Closed
jjisnow opened this issue Sep 15, 2022 · 1 comment · Fixed by #6582
Closed

EXIF prefix saved in WebP #6580

jjisnow opened this issue Sep 15, 2022 · 1 comment · Fixed by #6582

Comments

@jjisnow
Copy link

jjisnow commented Sep 15, 2022

What did you do?

I saved 2 copies of a webp file, one with exif=exif_bytes as shown, one without, then added the exif data by piexif.insert

What did you expect to happen?

exif data to be the same

What actually happened?

winmerge binary comparison reveals "Exif" is quoted one extra time in the Pillow image.save version indicating a coding error

What are your OS, Python and Pillow versions?

  • OS: Windows 10
  • Python: 3.8
  • Pillow: 9.2.0
from PIL import Image
import piexif
import piexif.helper

info = "test data in User Comment"
fullfn = "sample_image.webp"

exif_bytes = piexif.dump({
		"Exif": {
			piexif.ExifIFD.UserComment: piexif.helper.UserComment.dump(info, encoding="unicode")
		},
	})

with Image.open(fullfn) as image:
	image.save(fullfn, quality=60, exif=exif_bytes)

	image.save("sample_image_inserted_exif.webp", "webp", quality=60)

piexif.insert(exif_bytes, "sample_image_inserted_exif.webp")
@radarhere radarhere added the Exif label Sep 15, 2022
@radarhere radarhere changed the title webp exif data saving error EXIF prefix saved in WebP Sep 15, 2022
@radarhere radarhere added the WebP label Sep 15, 2022
@radarhere
Copy link
Member

I don't think this is an "error". Looking through our test images, flower.webp has the b"Exif\x00\x00" prefix, and flower2.webp does not.

I've created PR #6582 to resolve this, by removing the prefix when saving for the sake of smaller files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants