Skip to content

Image exif_transpose not working with Pillow 7 #4346

Closed
@jguerriat

Description

Hi!
First, sorry if my question is not fully documented, i'm not exactly used to work with pillow.

I'm working on a ERP called "odoo". When uploading a picture, it gets treated by pillow then saved into a filestore.
One of our client had a problem when trying to upload some of its picture. Some of then did work fine, others provoke this error:

  File "[...]parts/odoo/odoo/tools/image.py", line 383, in image_fix_orientation
    return ImageOps.exif_transpose(image)
  File "[...]lib/python3.6/site-packages/PIL/ImageOps.py", line 549, in exif_transpose
    transposed_image.info["exif"] = exif.tobytes()
  File "[...]lib/python3.6/site-packages/PIL/Image.py", line 3258, in tobytes
    return b"Exif\x00\x00" + head + ifd.tobytes(offset)
  File "[...]lib/python3.6/site-packages/PIL/TiffImagePlugin.py", line 808, in tobytes
    data = self._write_dispatch[typ](self, *values)
TypeError: write_undefined() takes 2 positional arguments but 5 were given

The Pillow version used is 7.0.0. (6.0.0 gave me another error, while 4.0.0 works fine!)

When i tried to modify the image (simply by rotating it in the default MacOs app: Preview), some exif information got deleted and then i was able to upload those pictures (i compared before/after exif using a website).

I tried to use an exif editor to check exactly what metadata caused this issue, but i wasnt able to find an editor that allowed me to edit the metadata "Orientation", which i highly suspect causes the issues.

In the original picture, the orientation metadata was: Rotate 90 CW
In the modified picture, the orientation metadata is: Horizontal (normal)

You'll find attached both image, if it can help you diagnose where the problem lies.

The first image works fine, the second one does not work.

WORK

DOES NOT WORK

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions