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

Getting TypeError when saving TIFF file #1524

Closed
chimezie opened this issue Nov 4, 2015 · 10 comments
Closed

Getting TypeError when saving TIFF file #1524

chimezie opened this issue Nov 4, 2015 · 10 comments
Labels

Comments

@chimezie
Copy link

chimezie commented Nov 4, 2015

The full traceback is at the bottom. This seems to occur only when the typ variable has a value of 1, in which case self._write_dispatch[typ] becomes <function ImageFileDirectory_v2._register_basic.. at 0x7f5b650e59d8>.

Traceback (most recent call last):
  File "/home/dev/workspace/video-generation/video_process.py", line 425, in generate_video
    self.mp4 = encode_video(self.listing, photos, str(music))
  File "/home/dev/workspace/video-generation/generation/encode.py", line 287, in encode_video
    with_address.save(str(filename))
  File "/home/dev/athena-venv/lib/python3.4/site-packages/PIL/Image.py", line 1665, in save
    save_handler(self, fp, filename)
  File "/home/dev/athena-venv/lib/python3.4/site-packages/PIL/TiffImagePlugin.py", line 1320, in _save
    offset = ifd.save(fp)
  File "/home/dev/athena-venv/lib/python3.4/site-packages/PIL/TiffImagePlugin.py", line 608, in save
    if len(data) <= 4:
TypeError: object of type 'int' has no len()
@radarhere radarhere added the TIFF label Nov 4, 2015
@radarhere
Copy link
Member

Thanks for reporting the problem. I don't suppose you'd be able to provide an image to demonstrate the problem? It would make debugging the issue easier.

@wiredfool
Copy link
Member

It's the metadata that's failing, so it's related to the big IFD rewrite that happened. I'd really need to see the image metadata to trace through why it's happening though.

@caspervdw
Copy link

I got exactly the same issue using matplotlib imsave. Matplotlib (at least, version 1.5) uses the PIL tiff writer.
See traceback and short discussion at soft-matter/trackpy#308.

@caspervdw
Copy link

caspervdw commented Nov 12, 2015

I had some more time to look at this problem. This code reproduces the problem with matplotlib 1.5 and Pillow 3.0.0:

import matplotlib.pyplot as plt
fig = plt.figure()
fig.savefig('temp.tif')

It seems to have something to do with tag 338, it is defined in TAGS_V2 to have type 1, which results in the exception.

@ttback
Copy link

ttback commented Nov 16, 2015

Had this exact same error last week. I had to roll back to Pillow 2.9.0 and everything works again.

@Nexuapex
Copy link
Contributor

This seems to appear on any RGBA image. It's trying to write the "ExtraSamples" tag, which only appears for RGBA and RGBX images.

@Nexuapex
Copy link
Contributor

As far as I can tell, write_byte does not handle being passed an int instead of a string, and the ExtraSamples tag is incorrectly typed as a byte instead of a short.

Nexuapex added a commit to Nexuapex/Pillow that referenced this issue Dec 1, 2015
@wiredfool
Copy link
Member

@radarhere
Copy link
Member

With the PR merged, this can be closed, yes?

@wiredfool
Copy link
Member

I don't think so, extra samples is not directly implicated in the original error, which was never tracked down.

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

No branches or pull requests

6 participants