-
Notifications
You must be signed in to change notification settings - Fork 803
Image color loss during conversion #201
Copy link
Copy link
Open
Description
Expected behavior
Please describe what you are expecting the library to perform.
The image does not lose color during conversion.
Actual behavior
Hello!
I'm using the thumbnailator library to compress and convert customers images to png (to default size 200x200).
One user came in with an image that was losing color (black gets lighter).
Perhaps the error is due to the fact that the original image was 16 BitsPerPixel - the result is 32 BitsPerPixel.
Perhaps I'm not using the library correctly.
Help me to understand.
Steps to reproduce the behavior
My code:
public static final Blob convertResizeImage(BufferedImage image, String formatName/*PNG*/, int targetWidth/*200*/, int targetHeight/*200*/) throws SQLException, IOException, InstantiationException, IllegalAccessException {
int imgType = image.getType();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
Thumbnails.of(image)
.size(targetWidth, targetHeight)
.outputFormat(formatName)
.imageType(imgType)
.outputQuality(1)
.toOutputStream(outputStream);
byte[] data = outputStream.toByteArray();
return bytes2Blob(data);
}
Environment
- OS vendor and version: Windows 10
- JDK vendor and version: Corretto 1.8
- Thumbnailator version: 0.4.18
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels

