coobird / thumbnailator

Thumbnailator - a thumbnail generation library for Java
MIT License
5.14k stars 784 forks source link

Thumbnail of PNG is wrong #135

Closed zhouxiangdev closed 4 years ago

zhouxiangdev commented 5 years ago

Expected behavior

Please describe what you are expecting the library to perform. I want to generate the thumbnail of one PNG file

Actual behavior

Please describe the actual behavior you are experiencing, including stack trace and other information which would help diagnose the issue. The source png file is this: 3 The generated thumbnail is this: thumbnail-3-1540439433067

The color is wrong, it is supposed to be red.

Steps to reproduce the behavior

Please enter step-by-step instructions for reproducing the actual behavior. Including code can be helpful in diagnosing issue, but please keep the code to a minimal that will reproduce the behavior. I checked the PNG file: (1200x628, 4-bit palette, non-interlaced, 98.5%). I think it is due to 4-bit palette which is not supported. After I convert to PNG-8 or PNG-24, no issue.

Environment

Please provide vendor and version information for the Operating System, JDK, and Thumbnailator. Please feel free to add any other information which may be pertinent.

coobird commented 4 years ago

Sorry for the late response. This appears to be a duplicate of #41.

You could try the workaround mentioned in https://github.com/coobird/thumbnailator/issues/41#issuecomment-330456553 -- basically add .imageType(BufferedImage.TYPE_INT_ARGB) to force Thumbnailator to process with transparencies enabled.

Hope this helps.