coobird / thumbnailator

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

outputQuality issue, make image lager. #122

Closed TrigoTao closed 7 years ago

TrigoTao commented 7 years ago

Expected behavior

outputQuality(x) should almost shrink image by x proportion.

Actual behavior

outputQuality(0.95) actually make the image larger.

Steps to reproduce the behavior

Thumbnails.of(ByteSource.wrap(source).openStream()).scale(1).outputQuality(0.95).toOutputStream(baos);

Environment

coobird commented 7 years ago

@TrigoTao, sorry for the late reply.

That's actually expected behavior. outputQuality is defined as follows:

Sets the output quality of the compression algorithm used to compress the thumbnail when it is written to an external destination such as a file or output stream.

Therefore, the final size of the image is up to the compression algorithm used, and it has no bearing on what the data size of the original image.

For example, if you have a JPEG that was compressed with a very low quality, but later, you save it with a high quality setting, you will likely end up with an image that takes up more storage space than the original image.

This behavior is by-design and expected.