we use the thumbnailator to scale images to a max-width or max-height (50px x 50px), but keeping the aspect ratio. For some reason, some scaled images have ugly stripes.
This is how we do it:
private static final int ICON_MAX_WIDTH = 50;
private static final int ICON_MAX_HEIGHT = 50;
public static byte[] createIconFromImageAsByteArray(final InputStream imageStream) throws IOException {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
Thumbnails.of(imageStream).width(ICON_MAX_WIDTH).height(ICON_MAX_HEIGHT).keepAspectRatio(true).outputFormat("png").toOutputStream(baos);
return baos.toByteArray();
}
This is the original image
This is the generated thumbnail
Maybe we are missing some option?
Thanks in advance,
paul
Hey there,
we use the thumbnailator to scale images to a max-width or max-height (50px x 50px), but keeping the aspect ratio. For some reason, some scaled images have ugly stripes.
This is how we do it:
This is the original image
This is the generated thumbnail
Maybe we are missing some option? Thanks in advance, paul