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

TypeError when trying to save a pyramidal TIFF as JPEG in Pillow 5.0.0 #3053

Closed
alexwlchan opened this issue Mar 23, 2018 · 4 comments
Closed
Labels
Bug Any unexpected behavior, until confirmed feature.

Comments

@alexwlchan
Copy link
Contributor

This was originally discovered in loris-imageserver/loris#415.

What did you do?

Create a tiled pyramidal TIFF from a JPEG with the following ImageMagick command:

$ convert --version
Version: ImageMagick 7.0.7-27 Q16 x86_64 2018-03-18 http://www.imagemagick.org
Copyright: © 1999-2018 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules
Delegates (built-in): bzlib freetype jng jpeg ltdl lzma png tiff xml zlib

$ convert speckle.jpg -define tiff:tile-geometry=256x256 -compress jpeg 'ptif:tiled_pyramidal_speckle.tif'

Open the file in Pillow and save it as a JPEG:

#!/usr/bin/env python
# -*- encoding: utf-8 -*-

from PIL import Image

im = Image.open('tiled_pyramidal_speckle.tif')
im.save('tiled_pyramidal_speckle.jpg')

What did you expect to happen?

A new JPEG would be created from the pyramidal TIFF, which resembled the original JPEG.

What actually happened?

In Pillow 4.3.0, the conversion succeeds.

In Pillow 5.0.0, I get a TypeError with the following traceback:

Traceback (most recent call last):
  File "pillow_example.py", line 7, in <module>
    im.save('tiled_pyramidal_speckle.jpg')
  File "/Users/alexwlchan/.virtualenvs/tempenv-4d7f2098295f/lib/python2.7/site-packages/PIL/Image.py", line 1897, in save
    self.load()
  File "/Users/alexwlchan/.virtualenvs/tempenv-4d7f2098295f/lib/python2.7/site-packages/PIL/TiffImagePlugin.py", line 1040, in load
    return super(TiffImageFile, self).load()
  File "/Users/alexwlchan/.virtualenvs/tempenv-4d7f2098295f/lib/python2.7/site-packages/PIL/ImageFile.py", line 204, in load
    args, self.decoderconfig)
  File "/Users/alexwlchan/.virtualenvs/tempenv-4d7f2098295f/lib/python2.7/site-packages/PIL/Image.py", line 435, in _getdecoder
    return decoder(mode, *args + extra)
TypeError: function takes at least 3 arguments (1 given)

What versions of Pillow and Python are you using?

In both cases, I’m using Python 3 on macOS in a fresh virtualenv:

$ python3 --version
Python 3.6.4

With Pillow 5.0.0:

$ pip freeze
Pillow==5.0.0

And with Pillow 4.3.0:

$ pip freeze
olefile==0.45.1
Pillow==4.3.0

I’ve attached a ZIP file to this issue which contains:

  • The original JPEG (speckle.jpg)
  • The script for generating the pyramidal TIF (converter.sh) and the TIF itself (tiled_pyramidal_speckle.tif)
  • A script that reproduces the Pillow error (pillow_example.py)
  • requirements.txt for both versions of Pillow

pillow_example.zip

@modou33
Copy link

modou33 commented Mar 26, 2018

Hello @alexwlchan thank you for having create a new thread I will close the loris-imageserver/loris#415

For answering your last question. this is a link real to one of my TIFF file http://176.31.193.99/loris/image.tif/info.json
If you're interested, I can provide the results I get in log file when you hit an query.

Unfortunately, originals tiled TIFF files are under licence, if need to get one of them, send me a private email on mdia@ajlsm.com. Then, I will be able to send you an example.

Thank a lot again!

@aclark4life aclark4life added the Bug Any unexpected behavior, until confirmed feature. label Apr 1, 2018
@radarhere
Copy link
Member

radarhere commented Aug 24, 2018

Testing, the breaking change is #2899. The compression mode used in the image here is 'jpeg', which was deliberately removed in that PR, due to 'colorspace issues' - #2899 (comment)

@kkopachev
Copy link
Contributor

I believe #3227 should fix reading tiled jpeg-compressed tiffs.

@radarhere
Copy link
Member

Testing, I find that #3227 does indeed resolve this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Any unexpected behavior, until confirmed feature.
Projects
None yet
Development

No branches or pull requests

5 participants