I was trying to process a dataset on the Detectron2 framework.
I expected the code to run with no exception.
TypeError: object of type 'int' has no len()
Here the complete stacktrace:
/home/cezar/Programs/anaconda3/envs/detectron/lib/python3.7/site-packages/PIL/TiffImagePlugin.py:603: UserWarning: Metadata Warning, tag 282 had too many entries: 2, expected 1
% (tag, len(values))
/home/cezar/Programs/anaconda3/envs/detectron/lib/python3.7/site-packages/PIL/TiffImagePlugin.py:603: UserWarning: Metadata Warning, tag 283 had too many entries: 2, expected 1
% (tag, len(values))
/home/cezar/Programs/anaconda3/envs/detectron/lib/python3.7/site-packages/PIL/TiffImagePlugin.py:603: UserWarning: Metadata Warning, tag 34853 had too many entries: 9, expected 1
% (tag, len(values))
Traceback (most recent call last):
File "test.py", line 21, in <module>
image = ImageOps.exif_transpose(image)
File "/home/cezar/Programs/anaconda3/envs/detectron/lib/python3.7/site-packages/PIL/ImageOps.py", line 549, in exif_transpose
transposed_image.info["exif"] = exif.tobytes()
File "/home/cezar/Programs/anaconda3/envs/detectron/lib/python3.7/site-packages/PIL/Image.py", line 3213, in tobytes
return b"Exif\x00\x00" + head + ifd.tobytes(offset)
File "/home/cezar/Programs/anaconda3/envs/detectron/lib/python3.7/site-packages/PIL/TiffImagePlugin.py", line 837, in tobytes
count = len(data)
TypeError: object of type 'int' has no len()
from PIL import Image, ImageOps
file_name = 'path/to/image/pt59.png'
with open(file_name, "rb") as f:
image = Image.open(f)
image = ImageOps.exif_transpose(image)
Here the link to the file:
https://www.dropbox.com/s/z5tc5zddqw20n15/pt59.zip?dl=0
This problem happened to 3 files from the whole dataset, since the images were proprocessed by the same script and taken from the same camera, I don't understand what might be wrong, or if it is a problem on the image or on the PIL library itself.
struct.error: argument out of range.Hi! Any ETA on when this makes a release? I'm encountering the very same issue and it's blocking me from releasing to production. Thanks!
Pillow releases quarterly, the next one is due 2020-01-01: https://github.com/python-pillow/Pillow/issues/4210.
I'm still having the same error on Pillow 7.0.0.
The UserWarning: Metadata Warning, tag 282 had too many entries: 2, expected 1 I mean
@rodrigoruiz do you have an image to demonstrate the warnings, that could be added to the test suite under the Pillow license?
@rodrigoruiz the warning on tag 282 should now be fixed in Pillow master, and will be part of the next Pillow release, due out on July 1.
Did this fix make it into Pillow 7.2.0? It was released June 30, not July 1, so not sure... I've attached a good test photo that triggers the error for me in pillow-simd 7.0.0
White dog looking at camera.jpg.zip
For people who land here and are using pillow-simd, the code in this PR is a solid workaround for this issue if you want to continue to use pillow-simd: https://github.com/facebookresearch/detectron2/pull/1666
Yep, https://github.com/python-pillow/Pillow/pull/4637 was merged on June 10 so made it into 7.2.0.