voole / thumbnailator

Automatically exported from code.google.com/p/thumbnailator
Other
0 stars 0 forks source link

Resized PNG file size is larger than original PNG file #77

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. original file 1.png file size is 371KB
2. after resized by thumbnailtor, the file size is 553KB
3. the option I tried is
Thumbnails.of(bi)
    .size(640, 428)
    .keepAspectRatio(true)
    .imageType(BufferedImage.TYPE_INT_ARGB)
    .outputFormat("png")
    .toOutputStream(response.getOutputStream());

What is the expected output? What do you see instead?
I expected that the resized file size would be similar to original image, but 
the file size of image resized by thumbnailator is 553kb

What version of the product are you using?
thumbnailator 0.4.8

On what operating system?
CentOS release 5.9 

Which version of Java?
java version "1.7.0_67"

Please provide any additional information below.

Original issue reported on code.google.com by jun...@gmail.com on 1 Jun 2015 at 5:05

Attachments:

GoogleCodeExporter commented 8 years ago
Sorry for the delayed response.

Resizing the original image to something smaller but ending up with a larger 
file could happen in a couple of circumstances. (At least which I can think of 
right now.)

1. If the original image was using a higher compression level than the final 
image.
2. If the final image is less compressible than the original image.

Since it appears that the dimensions of the original and file images are the 
same, I don't believe that (2) would apply to this case. (This case would 
generally happen to line drawings and such that have sharp contrast, which 
would be "smoothed out" when resized to a smaller image.)

I haven't taken a closer look at the original file, but I'm going to guess that 
the original image had a higher compression level than the final image.

What could generally be tried in this kind of case is to use the 
`outputQuality` method to change the compression level. However, I tried 
changing the compression level but was unable to affect the file size, which 
seems to indicate that the PNG encoder that is bundled with Java in my 
environment (Java 1.6, Ubuntu) may not support changing the compression level.

As such, there may not be a workaround to this issue.

However, please be aware that the purpose of Thumbnailator is to *resize* 
images rather than to recompress images with the same dimensions, so you may 
want to evaluate other means if you are trying to *reduce* the file size of 
images.

Original comment by coobird...@gmail.com on 16 Jun 2015 at 3:50

GoogleCodeExporter commented 8 years ago
The Thumbnailator project will move to GitHub due to the Google Project Hosting 
going read-only in one month.
http://google-opensource.blogspot.jp/2015/03/farewell-to-google-code.html

This issue will be tracked at GitHub at the following URL:
https://github.com/coobird/thumbnailator/issues/77

Original comment by coobird...@gmail.com on 25 Jul 2015 at 6:07