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

Partial preserving of Exif does not work of the "Exif" object is not preserved #3491

Closed
dtantsur opened this issue Dec 29, 2020 · 2 comments
Closed

Comments

@dtantsur
Copy link

The example in the docs does not actually work:

[2020-12-29 17:52:26] ERROR: render_galleries: Can't process galleries/...., using original image! ('Exif')
Traceback (most recent call last):
  File "/home/dtantsur/.local/lib/python3.8/site-packages/nikola/image_processing.py", line 163, in resize_image
    save_args['exif'] = piexif.dump(exif)
  File "/home/dtantsur/.local/lib/python3.8/site-packages/piexif/_dump.py", line 38, in dump
    exif_ifd = exif_dict["Exif"]
KeyError: 'Exif'

(I've modified the code to output the traceback).

The fix is very simple: change

                    if 'Exif' in exif:
                        exif["Exif"][piexif.ExifIFD.PixelXDimension] = w
                        exif["Exif"][piexif.ExifIFD.PixelYDimension] = h

to

                    if 'Exif' in exif:
                        exif["Exif"][piexif.ExifIFD.PixelXDimension] = w
                        exif["Exif"][piexif.ExifIFD.PixelYDimension] = h
                    else:
                        exif["Exif"] = {}

(I guess the same should be done for 0th).

@dtantsur dtantsur added the bug label Dec 29, 2020
@dtantsur
Copy link
Author

It's more of a bug in piexif: hMatoba/Piexif#114. Keeping this issue open for maintainers to decide if they want to land a workaround.

@Kwpolska
Copy link
Member

I believe this should be fixed in piexif.

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

No branches or pull requests

2 participants