plone / plone.scale

Contains image scaling logic for use in Zope environments. It supports Zope 2, Pyramid and other systems build on using the Zope ToolKit (ZTK).
https://pypi.org/project/plone.scale
2 stars 16 forks source link

New image scale sizes break cropping #53

Closed mauritsvanrees closed 2 years ago

mauritsvanrees commented 2 years ago

In Plone 6, cropping an image to the thumb scale works fine: you get a 128x128 image.

But how about the new preview scale? It is defined as 400 by 65536. That makes no sense for cropping. I saw this when adding tests. So how should we handle this? I propose:

I have a branch ready.

mauritsvanrees commented 2 years ago

In a Plone site using plone.scale without my PR, I tried a crop for real (instead of in tests). Some C code in Pillow prints this:

Maximum supported image dimension is 65500 pixels

And then I get a traceback:

2022-05-17 11:50:24,996 ERROR   [plone.namedfile.scaling:271][waitress-3] Could not scale "<plone.namedfile.file.NamedBlobImage object at 0x10f5cf040 oid 0x3b69 in <Connection at 10c194f70>>" of 'http://localhost:8080/Plone/img_20201118_180205016.jpg'
Traceback (most recent call last):
  File "/Users/maurits/shared-eggs/cp39/Pillow-9.1.0-py3.9-macosx-10.15-x86_64.egg/PIL/ImageFile.py", line 500, in _save
    fh = fp.fileno()
io.UnsupportedOperation: fileno

So if you ever see such a traceback, you are probably trying a too big crop or scale.