linpeixun / thumbnailator

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

Problem with resize gif images when output quality is set #9

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I found a problem with resizing gif files when I set output quality. I think it 
is possible to reproduce it with any gif file.

What steps will reproduce the problem?

Sample code:
Working:
BufferedImage bi = ImageIO.read(sourceFile);
        Thumbnails.of(bi).size(90, 63).keepAspectRatio(false).toFile(destFile);

Throwing exception version:
BufferedImage bi = ImageIO.read(sourceFile);
        Thumbnails.of(bi).size(90, 63).keepAspectRatio(false).outputQuality(0.8f).toFile(destFile);

What is the expected output? What do you see instead?
Stacktrace:
Exception in thread "main" java.lang.IllegalStateException: No compression type 
set!
    at javax.imageio.ImageWriteParam.setCompressionQuality(ImageWriteParam.java:1241)
    at net.coobird.thumbnailator.tasks.io.FileImageSink.write(Unknown Source)
    at net.coobird.thumbnailator.tasks.SourceSinkThumbnailTask.write(Unknown Source)
    at net.coobird.thumbnailator.Thumbnailator.createThumbnail(Unknown Source)
    at net.coobird.thumbnailator.Thumbnails$Builder.toFile(Unknown Source)
    at ImageResize.resizeImage(ImageResize.java:26)
    at ImageResize.main(ImageResize.java:18)

What version of the product are you using? On what operating system?
0.3.2

Original issue reported on code.google.com by tomasz.t...@gmail.com on 29 Apr 2011 at 9:10

GoogleCodeExporter commented 9 years ago
Thank you for the bug report.

The issue has been reproduced and work will start shortly.

Original comment by coobird...@gmail.com on 29 Apr 2011 at 11:50

GoogleCodeExporter commented 9 years ago

Original comment by coobird...@gmail.com on 29 Apr 2011 at 11:50

GoogleCodeExporter commented 9 years ago
The bug has been fixed.

A bug fix release (Thumbnailator 0.3.3) has just been released and is available 
for download.

Once again, thank you for taking the time to file an issue.

=======

Details about the issue:

Issue
-------

The issue was occurring due to the `FileImageSink` class not calling the 
`ImageWriterParam.setCompressionType` method, 
leading to a situation where the subsequent call to 
`ImageWriterParam.setCompressionQuality` causing an `IllegalStateException`.

(This exception-throwing behavior is documented in the Javadocs for the 
`ImageWriterParam.setCompressionQuality`.)

Fix
-------

The `FileImageSink` class (along with the `OutputStreamImageSink` class) has 
been fixed to call the `ImageWriterParam.setCompressionType` method
with the first compression type (if the compression type has not been set in 
the `ThumbnailParameter`) returned by the `ImageWriter`
for the specified output format. (If the `ImageWriter` doesn't provide any 
compression types, then the `ImageWriterParam.setCompressionType`
is not called.)

Original comment by coobird...@gmail.com on 29 Apr 2011 at 5:51

GoogleCodeExporter commented 9 years ago
8 hours after reporting the issue is fixed, really impressive, thanks!

Original comment by w.walc%c...@gtempaccount.com on 29 Apr 2011 at 5:56