thumbor / thumbor

thumbor is an open-source photo thumbnail service by globo.com

Home Page:http://thumbor.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Resizing image with transparent background causes transparency loss

tahir-wasim opened this issue · comments

Thumbor request URL

http://localhost/unsafe/x30/1065/sprouts.png
sprouts

Expected behaviour

image should be resized while maintaining transparency

Actual behaviour

sprouts_distorted
Image becomes blurry with black background
Debug logs:

2023-10-12 17:23:46 PIL.PngImagePlugin:DEBUG STREAM b'IHDR' 16 13
2023-10-12 17:23:46 PIL.PngImagePlugin:DEBUG STREAM b'PLTE' 41 36
2023-10-12 17:23:46 PIL.PngImagePlugin:DEBUG STREAM b'tRNS' 89 10
2023-10-12 17:23:46 PIL.PngImagePlugin:DEBUG STREAM b'IDAT' 111 7086
2023-10-12 17:23:46 thumbor:DEBUG converting image from 8-bit/1-bit palette to 32-bit RGB(A) for resize
2023-10-12 17:23:46 thumbor:DEBUG No image format specified. Retrieving from the image extension: .png.
2023-10-12 17:23:46 thumbor:DEBUG Content Type of image/png detected.
  Recompressing IDAT chunks in /tmp/tmpnbqk01y5 to /tmp/tmp39tq161d
   Total length of data found in critical chunks            =      1760
libpng warning: Invalid number of transparent colors specified
   Best pngcrush method        =   7 (ws 12 fm 0 zl 9 zs 0) =      1196
CPU time decode 0.003021, encode 0.005513, other 0.009735, total 0.018786 sec

Operating system

Ubuntu

Dependencies

envtpl==0.7.2
remotecv==3.1.0
boto==2.49.0
tornado-botocore==1.5.0
python-dateutil
dateutils==0.6.12
shortuuid==1.0.8
redis==3.5.3
raven==6.10.0
cairosvg==2.5.2
pycurl==7.45.2
tc-aws==7.0.2
tc-core==0.5
thumbor==7.6.0
thumbor-wand-engine==0.1.1

This issue is stale because it has been open 30 days with no activity. Remove the stale label or add a comment, or this issue will be closed in 15 days. You can always re-open if you still feel this is still an issue. Tag @heynemann for more information.

Thanks for reaching out. Could you please post your thumbor.conf and your version of thumbor you're using, to provide a minimum reproduceable build?

turns out the issue was in the interaction of the optimizer pngcrush and library libpng. It doesn't recover from this warning:

libpng warning: Invalid number of transparent colors specified

I switched to optipng and it works better. Closing the issue