feexon / thumbnailator

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

Exception thrown when attempting to resize a CMYK JPEG #48

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Thumbnails.of(new 
File("/Users/wq/Downloads/covecfe6c5888b1e.JPG")).size(100,100).toFile(new 
File("/Users/wq/Downloads/abc.jpg"));
2.
3.

What is the expected output? What do you see instead?

What version of the product are you using? On what operating system? Which
version of Java (Sun/Oracle? OpenJDK?) ?
MacOSX,oracle-jdk7.

Please provide any additional information below.
javax.imageio.IIOException: Improper call to JPEG library in state 202
    at com.sun.imageio.plugins.jpeg.JPEGImageReader.readImageHeader(Native Method)
    at com.sun.imageio.plugins.jpeg.JPEGImageReader.readNativeHeader(JPEGImageReader.java:550)
    at com.sun.imageio.plugins.jpeg.JPEGImageReader.checkTablesOnly(JPEGImageReader.java:295)
    at com.sun.imageio.plugins.jpeg.JPEGImageReader.gotoImage(JPEGImageReader.java:427)
    at com.sun.imageio.plugins.jpeg.JPEGImageReader.readHeader(JPEGImageReader.java:543)
    at com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal(JPEGImageReader.java:986)
    at com.sun.imageio.plugins.jpeg.JPEGImageReader.read(JPEGImageReader.java:966)
    at javax.imageio.ImageReader.read(ImageReader.java:940)
    at net.coobird.thumbnailator.tasks.io.FileImageSource.read(Unknown Source)
    at net.coobird.thumbnailator.tasks.SourceSinkThumbnailTask.read(Unknown Source)
    at net.coobird.thumbnailator.Thumbnailator.createThumbnail(Unknown Source)
    at net.coobird.thumbnailator.Thumbnails$Builder.toFile(Unknown Source)

Original issue reported on code.google.com by clay...@gmail.com on 26 Jun 2013 at 8:19

GoogleCodeExporter commented 9 years ago
Hi,

Thank you for reporting this issue.

However, I will not be able to reproduce the issue without an example of the 
JPEG which is causing the problem.
(Furthermore, I won't be able to try this on a Mac, so I'll have to try on a 
Linux machine...)

Also, as an addition, this may be a problem with libjpeg, which is what I 
assume is being used by the Java Image I/O implementation:

A quick grep from the sources obtained from 
http://www.ijg.org/files/jpegsrc.v9.tar.gz:

  $ grep -R "Improper call to JPEG library in state" .
  ./jerror.h:JMESSAGE(JERR_BAD_STATE, "Improper call to JPEG library in state %d")

  $ grep -R "JERR_BAD_STATE" .
  ./jdapistd.c:    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
  ./jdapistd.c:    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
  ./jdapistd.c:    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
  ./jdapistd.c:    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
  ./jdapistd.c:    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
  ./jctrans.c:    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
  ./jctrans.c:    ERREXIT1(dstinfo, JERR_BAD_STATE, dstinfo->global_state);
  ./jdmaster.c:    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
  ./jdmaster.c:    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
  ./jcparam.c:    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
  ./jcparam.c:    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
  ./jcparam.c:    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
  ./jcparam.c:    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
  ./jdapimin.c:    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
  ./jdapimin.c:    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
  ./jdapimin.c:    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
  ./jdapimin.c:    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
  ./jdapimin.c:    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
  ./jcapimin.c:    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
  ./jcapimin.c:    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
  ./jcapimin.c:    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
  ./jcapimin.c:    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
  ./jerror.h:JMESSAGE(JERR_BAD_STATE, "Improper call to JPEG library in state %d")
  ./jcapistd.c:    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
  ./jcapistd.c:    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
  ./jcapistd.c:    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
  ./jdtrans.c:  ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);

If this is caused by the underlying implementation of the Java JPEG reader, 
this is not much that can be done to avoid this problem in Thumbnailator.

Original comment by coobird...@gmail.com on 16 Jul 2013 at 3:26

GoogleCodeExporter commented 9 years ago

Original comment by coobird...@gmail.com on 8 Sep 2013 at 2:22