mecnet / thumbnailator

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

Low quality when resizing a GIF image #65

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

I'm using thumbnailator-0.4.7

the code is
Thumbnails.of(srcImage).width(200).outputQuality(1f).toFile(saveImage); 

the testing image is in attachment (original.gif)

aftering processing, the color of image was not right, a slight different

Original issue reported on code.google.com by song...@gmail.com on 17 Jan 2014 at 7:49

Attachments:

GoogleCodeExporter commented 9 years ago
I changed the code to
Thumbnails.of(srcImage).size(80,80).outputFormat("gif").toFile(new 
File("/Users/hi/Desktop/1.gif"));

specified the output format to gif, and replaced '.width(200)' with 
'.size(80,80)'

but the quality still low (1.gif)

the 3.gif was created by another 3rd part imaging library

Original comment by song...@gmail.com on 20 Jan 2014 at 3:40

Attachments:

GoogleCodeExporter commented 9 years ago
Thank you for filing this issue.

I have been able to reproduce this issue, and turns out there is a workaround:

  Thumbnails.of("original.gif")
    .size(80, 80)
    .imageType(BufferedImage.TYPE_INT_ARGB)
    .toFile("thumbnail.gif");

The issue appears to be that internally, Thumbnailator is resizing the 8-bit 
image itself, which can cause low quality image resizing.
(Note: This is a similar issue to Issue 26.)

The `imageType(BufferedImage.TYPE_INT_ARGB)` method call forces Thumbnailator 
to convert the original image to a 24-bit image with transparency when 
performing the resizing operation which leads to the better resize quality.

Also, just to note, Thumbnailator will do its best to try to determine the 
output format from the file name (if a file name is provided), so at least in 
the case you've presented, using `outputFormat("gif")` is not necessary.

Although this does not directly address the issue (there shouldn't be a need to 
call the `imageType` method -- Thumbnailator should be smart enough to do it 
automatically) so I'm going to leave this issue open.

Original comment by coobird...@gmail.com on 31 Jan 2014 at 4:12

GoogleCodeExporter commented 9 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 has been migrated to GitHub at the following URL:
https://github.com/coobird/thumbnailator/issues/65

Original comment by coobird...@gmail.com on 25 Jul 2015 at 10:54