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: function takes at least 3 arguments (1 given) #415

Closed
modou33 opened this issue Mar 23, 2018 · 9 comments
Closed

TypeError: function takes at least 3 arguments (1 given) #415

modou33 opened this issue Mar 23, 2018 · 9 comments

Comments

@modou33
Copy link

modou33 commented Mar 23, 2018

Hello.

I've successfully installed and configured the last version of loris. When I query server for getting the info.json file of an image all work nice.
However all others query (exemple: <http://host/ ...>/full/224,/0/default.jpg) return and error 500. On the log I get this trace

==> error.log <==
[Fri Mar 23 10:57:08.008736 2018] [wsgi:error] [pid 16926] [remote 109.190.129.96:40453] mod_wsgi (pid=16926): Exception occurred processing WSGI script '/var/www/loris2/loris2.wsgi'.
[Fri Mar 23 10:57:08.008949 2018] [wsgi:error] [pid 16926] [remote 109.190.129.96:40453] Traceback (most recent call last):
[Fri Mar 23 10:57:08.009032 2018] [wsgi:error] [pid 16926] [remote 109.190.129.96:40453]   File "/usr/local/lib/python2.7/dist-packages/Loris-2.3.1-py2.7.egg/loris/webapp.py", line 447, in __call__
[Fri Mar 23 10:57:08.009122 2018] [wsgi:error] [pid 16926] [remote 109.190.129.96:40453]     return self.wsgi_app(environ, start_response)
[Fri Mar 23 10:57:08.009180 2018] [wsgi:error] [pid 16926] [remote 109.190.129.96:40453]   File "/usr/local/lib/python2.7/dist-packages/Loris-2.3.1-py2.7.egg/loris/webapp.py", line 390, in wsgi_app
[Fri Mar 23 10:57:08.009244 2018] [wsgi:error] [pid 16926] [remote 109.190.129.96:40453]     response = self.route(request)
[Fri Mar 23 10:57:08.009333 2018] [wsgi:error] [pid 16926] [remote 109.190.129.96:40453]   File "/usr/local/lib/python2.7/dist-packages/Loris-2.3.1-py2.7.egg/loris/webapp.py", line 441, in route
[Fri Mar 23 10:57:08.009398 2018] [wsgi:error] [pid 16926] [remote 109.190.129.96:40453]     return self.get_img(request, ident, region, size, rotation, quality, fmt, base_uri)
[Fri Mar 23 10:57:08.009454 2018] [wsgi:error] [pid 16926] [remote 109.190.129.96:40453]   File "/usr/local/lib/python2.7/dist-packages/Loris-2.3.1-py2.7.egg/loris/webapp.py", line 662, in get_img
[Fri Mar 23 10:57:08.009518 2018] [wsgi:error] [pid 16926] [remote 109.190.129.96:40453]     image_info=info
[Fri Mar 23 10:57:08.009574 2018] [wsgi:error] [pid 16926] [remote 109.190.129.96:40453]   File "/usr/local/lib/python2.7/dist-packages/Loris-2.3.1-py2.7.egg/loris/webapp.py", line 724, in _make_image
[Fri Mar 23 10:57:08.009634 2018] [wsgi:error] [pid 16926] [remote 109.190.129.96:40453]     image_info=image_info
[Fri Mar 23 10:57:08.009680 2018] [wsgi:error] [pid 16926] [remote 109.190.129.96:40453]   File "/usr/local/lib/python2.7/dist-packages/Loris-2.3.1-py2.7.egg/loris/transforms.py", line 197, in transform
[Fri Mar 23 10:57:08.009733 2018] [wsgi:error] [pid 16926] [remote 109.190.129.96:40453]     image_info=image_info
[Fri Mar 23 10:57:08.009778 2018] [wsgi:error] [pid 16926] [remote 109.190.129.96:40453]   File "/usr/local/lib/python2.7/dist-packages/Loris-2.3.1-py2.7.egg/loris/transforms.py", line 128, in _derive_with_pil
[Fri Mar 23 10:57:08.009831 2018] [wsgi:error] [pid 16926] [remote 109.190.129.96:40453]     im = im.resize(wh, resample=Image.ANTIALIAS)
[Fri Mar 23 10:57:08.009876 2018] [wsgi:error] [pid 16926] [remote 109.190.129.96:40453]   File "/usr/local/lib/python2.7/dist-packages/PIL/Image.py", line 1745, in resize
[Fri Mar 23 10:57:08.009931 2018] [wsgi:error] [pid 16926] [remote 109.190.129.96:40453]     self.load()
[Fri Mar 23 10:57:08.009976 2018] [wsgi:error] [pid 16926] [remote 109.190.129.96:40453]   File "/usr/local/lib/python2.7/dist-packages/PIL/TiffImagePlugin.py", line 1040, in load
[Fri Mar 23 10:57:08.010029 2018] [wsgi:error] [pid 16926] [remote 109.190.129.96:40453]     return super(TiffImageFile, self).load()
[Fri Mar 23 10:57:08.010074 2018] [wsgi:error] [pid 16926] [remote 109.190.129.96:40453]   File "/usr/local/lib/python2.7/dist-packages/PIL/ImageFile.py", line 204, in load
[Fri Mar 23 10:57:08.010126 2018] [wsgi:error] [pid 16926] [remote 109.190.129.96:40453]     args, self.decoderconfig)
[Fri Mar 23 10:57:08.010171 2018] [wsgi:error] [pid 16926] [remote 109.190.129.96:40453]   File "/usr/local/lib/python2.7/dist-packages/PIL/Image.py", line 435, in _getdecoder
[Fri Mar 23 10:57:08.010223 2018] [wsgi:error] [pid 16926] [remote 109.190.129.96:40453]     return decoder(mode, *args + extra)
[Fri Mar 23 10:57:08.010278 2018] [wsgi:error] [pid 16926] [remote 109.190.129.96:40453] TypeError: function takes at least 3 arguments (1 given)

For information, I'm working with Tiff files and:
Ubuntu 16.04
Python 2.7.12
Apache 2.4

Thank you for you help.

@alexwlchan
Copy link
Contributor

Please could you run pip freeze and paste the output here? Along with the contents of loris2.wsgi.

I’m particularly interested in your version of Pillow – I wonder if this is related to #405?

@modou33
Copy link
Author

modou33 commented Mar 23, 2018

hello @alexwlchan thank your for you fast reply.

the content of pip freeze

pip freeze
agentarchives==0.4.0
asn1crypto==0.24.0
attrs==17.4.0
bagit==1.5.2
beautifulsoup4==4.4.1
certifi==2018.1.18
cffi==1.11.5
chardet==3.0.4
configobj==5.0.6
cookies==2.2.1
cryptography==2.1.4
DeepZoomTools==1.0.0
Django==1.8.18
django-annoying==0.7.7
django-autoslug==1.9.3
django-braces==1.0.0
django-extensions==1.1.1
django-forms-bootstrap==3.1.0
django-model-utils==1.3.1
django-mysqlpool==0.1.post9
django-tastypie==0.13.2
elasticsearch==1.9.0
enum34==1.1.6
funcsigs==1.0.2
gearman==2.0.2
gunicorn==19.4.5
gyp==0.1
html5lib==0.999
idna==2.6
image==1.5.15
ipaddress==1.0.19
lazy-paged-sequence==0.3
logutils==0.3.3
Loris==2.3.1
lxml==3.5.0
metsrw==0.1.0
mock==2.0.0
mysqlclient==1.3.9
ndg-httpsclient==0.4.4
netaddr==0.7.19
numpy==1.11.0
olefile==0.45.1
opf-fido==1.3.6
pbr==3.1.1
Pillow==5.0.0
pyasn1==0.4.2
pycparser==2.18
PyJWT==1.5.3
pyOpenSSL==17.5.0
python-dateutil==2.4.2
python-mimeparse==1.6.0
pytz==2018.3
requests==2.7.0
responses==0.8.1
simplejson==3.8.1
six==1.11.0
slumber==0.6.0
SQLAlchemy==1.2.4
Unidecode==0.4.19
urllib3==1.22
Werkzeug==0.14.1
You are using pip version 9.0.1, however version 9.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

the content of loris2.wsgi

#!/usr/bin/env python
from loris.webapp import create_app
# Uncomment and configure below if you are using virtualenv
# import site
# site.addsitedir('/path/to/my/virtualenv/lib/python2.x/site-packages')
application = create_app(config_file_path='/etc/loris2/loris2.conf')

thanks !

@alexwlchan
Copy link
Contributor

Okay, try running pip install Pillow==4.3.0, and see if you can still reproduce the error. I think this is an issue in Pillow 5.0.0.

If that works, can you tell me which bit of the docs you were reading that led you down this install path? Sounds like we need a warning there!

@modou33
Copy link
Author

modou33 commented Mar 23, 2018

By installing Pillow 4.3.0 it works nice when I query a jpeg image
However, when I query a tiff file I still get an error 500 with the trace below

[Fri Mar 23 12:58:48.690673 2018] [wsgi:error] [pid 19390] [remote 109.190.129.96:51662] mod_wsgi (pid=19390): Exception occurred processing WSGI script '/var/www/loris2/loris2.wsgi'.
[Fri Mar 23 12:58:48.690805 2018] [wsgi:error] [pid 19390] [remote 109.190.129.96:51662] Traceback (most recent call last):
[Fri Mar 23 12:58:48.690851 2018] [wsgi:error] [pid 19390] [remote 109.190.129.96:51662]   File "/usr/local/lib/python2.7/dist-packages/Loris-2.3.1-py2.7.egg/loris/webapp.py", line 447, in __call__
[Fri Mar 23 12:58:48.690914 2018] [wsgi:error] [pid 19390] [remote 109.190.129.96:51662]     return self.wsgi_app(environ, start_response)
[Fri Mar 23 12:58:48.690946 2018] [wsgi:error] [pid 19390] [remote 109.190.129.96:51662]   File "/usr/local/lib/python2.7/dist-packages/Loris-2.3.1-py2.7.egg/loris/webapp.py", line 390, in wsgi_app
[Fri Mar 23 12:58:48.690985 2018] [wsgi:error] [pid 19390] [remote 109.190.129.96:51662]     response = self.route(request)
[Fri Mar 23 12:58:48.691017 2018] [wsgi:error] [pid 19390] [remote 109.190.129.96:51662]   File "/usr/local/lib/python2.7/dist-packages/Loris-2.3.1-py2.7.egg/loris/webapp.py", line 441, in route
[Fri Mar 23 12:58:48.691055 2018] [wsgi:error] [pid 19390] [remote 109.190.129.96:51662]     return self.get_img(request, ident, region, size, rotation, quality, fmt, base_uri)
[Fri Mar 23 12:58:48.691087 2018] [wsgi:error] [pid 19390] [remote 109.190.129.96:51662]   File "/usr/local/lib/python2.7/dist-packages/Loris-2.3.1-py2.7.egg/loris/webapp.py", line 662, in get_img
[Fri Mar 23 12:58:48.691123 2018] [wsgi:error] [pid 19390] [remote 109.190.129.96:51662]     image_info=info
[Fri Mar 23 12:58:48.691155 2018] [wsgi:error] [pid 19390] [remote 109.190.129.96:51662]   File "/usr/local/lib/python2.7/dist-packages/Loris-2.3.1-py2.7.egg/loris/webapp.py", line 724, in _make_image
[Fri Mar 23 12:58:48.691191 2018] [wsgi:error] [pid 19390] [remote 109.190.129.96:51662]     image_info=image_info
[Fri Mar 23 12:58:48.691223 2018] [wsgi:error] [pid 19390] [remote 109.190.129.96:51662]   File "/usr/local/lib/python2.7/dist-packages/Loris-2.3.1-py2.7.egg/loris/transforms.py", line 197, in transform
[Fri Mar 23 12:58:48.691262 2018] [wsgi:error] [pid 19390] [remote 109.190.129.96:51662]     image_info=image_info
[Fri Mar 23 12:58:48.691294 2018] [wsgi:error] [pid 19390] [remote 109.190.129.96:51662]   File "/usr/local/lib/python2.7/dist-packages/Loris-2.3.1-py2.7.egg/loris/transforms.py", line 128, in _derive_with_pil
[Fri Mar 23 12:58:48.691333 2018] [wsgi:error] [pid 19390] [remote 109.190.129.96:51662]     im = im.resize(wh, resample=Image.ANTIALIAS)
[Fri Mar 23 12:58:48.691365 2018] [wsgi:error] [pid 19390] [remote 109.190.129.96:51662]   File "/usr/local/lib/python2.7/dist-packages/PIL/Image.py", line 1743, in resize
[Fri Mar 23 12:58:48.691405 2018] [wsgi:error] [pid 19390] [remote 109.190.129.96:51662]     self.load()
[Fri Mar 23 12:58:48.691437 2018] [wsgi:error] [pid 19390] [remote 109.190.129.96:51662]   File "/usr/local/lib/python2.7/dist-packages/PIL/TiffImagePlugin.py", line 1053, in load
[Fri Mar 23 12:58:48.691475 2018] [wsgi:error] [pid 19390] [remote 109.190.129.96:51662]     return super(TiffImageFile, self).load()
[Fri Mar 23 12:58:48.691507 2018] [wsgi:error] [pid 19390] [remote 109.190.129.96:51662]   File "/usr/local/lib/python2.7/dist-packages/PIL/ImageFile.py", line 206, in load
[Fri Mar 23 12:58:48.691544 2018] [wsgi:error] [pid 19390] [remote 109.190.129.96:51662]     decoder.setimage(self.im, extents)
[Fri Mar 23 12:58:48.691585 2018] [wsgi:error] [pid 19390] [remote 109.190.129.96:51662] ValueError: tile cannot extend outside image

the tiff files are tiled pyramidal. There are builded from jpeg file by using imageMagick with this type of command:
convert s -define tiff:tile-geometry=256x256 -compress jpeg 'ptif:o.tif'

thanks !

@bcail
Copy link
Contributor

bcail commented Mar 23, 2018

@modou33 could you please post the info.json file for this image, and the IIIF URL you're hitting when you get this error?

@modou33
Copy link
Author

modou33 commented Mar 23, 2018

The info.json is

{
  "profile": [
    "http://iiif.io/api/image/2/level2.json",
    {
      "supports": [
        "canonicalLinkHeader",
        "profileLinkHeader",
        "mirroring",
        "rotationArbitrary",
        "regionSquare",
        "sizeAboveFull"
      ],
      "qualities": [
        "default",
        "color",
        "gray",
        "bitonal"
      ],
      "formats": [
        "jpg",
        "png",
        "gif",
        "webp"
      ]
    }
  ],
  "protocol": "http://iiif.io/api/image",
  "sizes": [],
  "height": 4981,
  "width": 7451,
  "@context": "http://iiif.io/api/image/2/context.json",
  "@id": "http://<masked host>/loris/<masked ID>image.jpg.tif"
}

Except the info.json all other IIIF query fail with an error 500. For exemple:
<image id>/full/full/0/default.jpg

thanks !

@bcail
Copy link
Contributor

bcail commented Mar 23, 2018

Maybe Pillow can't handle tiled pyramidal tiffs? @modou33, if you'd be interested in looking into this more, and even submitting a PR to add support, that'd be great. Otherwise, at least we have this issue as a feature request.

@alexwlchan
Copy link
Contributor

This looks like a likely candidate for the "ValueError: tile cannot extend outside image" in 4.3.0: python-pillow/Pillow#3044

The TypeError looks like it might just be a Pillow bug. I’ll file it against the Pillow repo.

@alexwlchan
Copy link
Contributor

alexwlchan commented Mar 23, 2018

I’ve raised python-pillow/Pillow#3053 to track the TypeError, which looks like another bug in Pillow 5’s handling of TIFs. (See also: #405 and python-pillow/Pillow#2926.) That includes a test image that we can use in the Loris test suite, if necessary.

I’m unable to reproduce the ValueError with my test image, so maybe there’s something else at play here.

@modou33 Are you able to provide the exact IIIF requests you’re making to Loris? I’m poking around with the region parameter but unable to hit this error. Even better, would it be possible to share one of your images? (I realise the latter may be trickier!)

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

No branches or pull requests

3 participants