coobird / thumbnailator

Thumbnailator - a thumbnail generation library for Java
MIT License
5.17k stars 789 forks source link

Stripes after creating thumbnail #98

Closed ppasler closed 8 years ago

ppasler commented 8 years ago

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:

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 google

This is the generated thumbnail google png_scaled

Maybe we are missing some option? Thanks in advance, paul

euleule commented 8 years ago

Hi @ppasler ,

this relates to #26 and the suggested fix works fine for us.

Best regards, Robert

ppasler commented 8 years ago

Thanks @euleule,

didn't relate these issues. Good job!

regards, paul