Skip to content

Commit

Permalink
🐛(dev): Fix exif encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
Isotr0py committed Mar 10, 2024
1 parent 4acfde1 commit 4c38c10
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pillow_jxl/JpegXLImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,22 @@ def _save(im, fp, filename, save_all=False):
use_container=use_container,
)
# FIXME (Isotr0py): im.filename maybe None if parse stream
# TODO (Isotr0py): This part should be refactored
# TODO (Isotr0py): This part should be refactored in the near future
if im.format == "JPEG" and im.filename:
with open(im.filename, "rb") as f:
data = enc(f.read(), im.width, im.height, jpeg_encode=True, metadata={})
else:
exif = info.get("exif", b"")
exif = info.get("exif", im.getexif().tobytes())
if exif and exif.startswith(b"Exif\x00\x00"):
exif = exif[6:]
metadata = {
"exif": exif,
"jumb": info.get("jumb", b""),
"xmp": info.get("xmp", b""),
}
data = enc(im.tobytes(), im.width, im.height, jpeg_encode=False, metadata=metadata)
data = enc(
im.tobytes(), im.width, im.height, jpeg_encode=False, metadata=metadata
)
fp.write(data)


Expand Down

0 comments on commit 4c38c10

Please sign in to comment.