TwelveMonkeys icon indicating copy to clipboard operation
TwelveMonkeys copied to clipboard

Unable to load JPG images due to "Unsupported JPEG process: SOF type 0xcb"

Open sgoeschl opened this issue 10 years ago ā€¢ 8 comments

Before starting the bug report - you also save my day :-)

For a few images I get the error message

Unsupported JPEG process: SOF type 0xcb

[ERROR] [2014.03.26 09:53:49]  Loading the image failed  : /iad/styria/prod/htdocs/uploads/20140301_123857_2363439246058001517.jpg [Environment: Host: "www.willhaben.at" Action: "swfuploadimage" Action Class name: "null" Sequence #: "135192664" Referer: "null" URL: "/swfuploadimage" RemoteIP: "212.152.181.235" User-Agent: "Shockwave Flash" jsessionid=3AD5B5AC
CAC4F054C1F1EEA4FE891D51&[email protected]]  at no.finntech.base.modules.scale.ScaleJavaOnly.createImageFromImageFile(ScaleJavaOnly.java:282)
javax.imageio.IIOException: Unsupported JPEG process: SOF type 0xcb
        at com.sun.imageio.plugins.jpeg.JPEGImageReader.readImage(Native Method)
        at com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal(JPEGImageReader.java:1231)
        at com.sun.imageio.plugins.jpeg.JPEGImageReader.read(JPEGImageReader.java:1034)
        at com.twelvemonkeys.imageio.plugins.jpeg.JPEGImageReader.read(Unknown Source)
        at javax.imageio.ImageIO.read(ImageIO.java:1448)
        at javax.imageio.ImageIO.read(ImageIO.java:1308)

Not an expert but

  • it might stem from an unsupported compression type "Lossless (sequential arith)"
  • it might not stem at all from your library

I attached the offending image

Cheers,

Siegfried Goeschl

test-image-broken-01

sgoeschl avatar Mar 26 '14 16:03 sgoeschl

Hi Siegfried,

Thanks for reporting! And for the positive feedback! :-)

Unfortunately, I don't think there's much I can do to fix this at the moment.

What my reader does, it basically take responsibility for parsing the JFIF structure and handle metadata, color space information etc. The actual JPEG decoding is delegated to the com.sun...JPEGImageReader, which in turn uses IJG native code (libJPEG). And at the moment the version used in the JRE doesn't support lossless mode, nor arithmetic encoding.

I have thought about creating wrappers for other native JPEG libraries (like libJPEGTurbo or other), or even writing a pure Java JPEG decoder (they've written one in JavaScript, so how hard could it be..? ;-) I don't have the time to do it myself, but it's certainly doable if anyone would like to collaborate.

PS; The attached image seems broken/incomplete, the lower/left part, depending on orientation, is missing. Is your version the same?

Best regards,

Harald K

haraldk avatar Mar 27 '14 08:03 haraldk

Hi Harald,

@Implementation - that was pretty much my understanding :-)

@Collaboration - not an expert and already overworked - are there any Open Source business friendly (BSD, ASL) Java libraries around which could serve as starting point, such as Batik and Sanselan? Starting from the scratch is a waste of time but adding some compression support for an existing code base seems doable.

@Publicity - I had a hard time finding your library - thought of writing an article? I naively started to convert images for two customer projects and it seems more of a mine field than a "Spaziergang". And information is sparse regarding potential image conversion problems (JPEG encodings, Alpha Channel support in JDK, CMYK, broken metadata, multipage TIFF)

@Broken Image - the original image looks okay but I think GitHub has also problems processing the image. I' m converting a lot of images and could update you with trouble-some images

Cheers,

Siegfried Goeschl

sgoeschl avatar Mar 27 '14 09:03 sgoeschl

Hi again,

About the collaboration, yes, that would be nice. Let me know if you find anything. ;-) I have looked at the Java-based JPEG reader from Commons Imaging (formerly known as Sanselan), but it's not really in a state that I find useful yet.

Publicity, yes, maybe I should do that. However, time is sparse, and my only focus now is to implement the last features, fix bugs and get the new release out. Maybe after that, or if someone would like to help out.

More test-images are always welcome!

Best regards,

Harald K

haraldk avatar Apr 01 '14 11:04 haraldk

Hi Harald,

I hate to be a smart ass (not very smart anyway) but publicity IS important - it took ages to find your stuff in the internet. And Open Sourcing had work makes only fun if someone is using it :-)

A few suggestions for a joint-venture

  • What about writing a joint article for the Java Magazin (see http://jaxenter.de/java-magazin)?! I
  • Answering the CfP for Java2Days in Sofia? It should be possible to get a speaking slot there

In case you are wondering about my motivation (rightly so)

  • I really appreciate your software since you saved my day
  • I hate the fact that there is brilliant software out there nobody knows
  • I try to put something on my CV every year (paper and/or conference speaker)
  • Iā€™m an Apache Software Foundation Member doing a lot of community work
  • I can provide the motivation story you can fill out with the technical stuff

Cheers,

Siegfried Goeschl http://people.apache.org/~sgoeschl/index.html

On 01 Apr 2014, at 05:45, Harald Kuhr [email protected] wrote:

Hi again,

About the collaboration, yes, that would be nice. Let me know if you find anything. ;-) I have looked at the Java-based JPEG reader from Commons Imaging (formerly known as Sanselan), but it's not really in a state that I find useful yet.

Publicity, yes, maybe I should do that. However, time is sparse, and my only focus now is to implement the last features, fix bugs and get the new release out. Maybe after that, or if someone would like to help out.

More test-images are always welcome!

Best regards,

Harald K

ā€” Reply to this email directly or view it on GitHub.

sgoeschl avatar Apr 09 '14 00:04 sgoeschl

Hi

Sven Gothel wrote a JPEG decoder, he ported it from Javascript, you can find it in JOGL: https://github.com/sgothel/jogl/blob/master/src/jogl/classes/jogamp/opengl/util/jpeg/JPEGDecoder.java https://github.com/sgothel/jogl/blob/master/src/jogl/classes/com/jogamp/opengl/util/texture/spi/JPEGImage.java

ghost avatar Mar 29 '16 14:03 ghost

I see this old issue is still open. Just going to mention that with the code from this issue: https://github.com/haraldk/TwelveMonkeys/issues/197

The exception is logged and the image is processed properly.

KoenDG avatar Jan 28 '20 18:01 KoenDG

@KoenDG Thanks for looking into this and taking the time to test! šŸ˜€

Perhaps we should add the code from #197 to the documentation on the home page?

Best regards,

-- Harald K

haraldk avatar Jan 29 '20 19:01 haraldk

@KoenDG Thanks for looking into this and taking the time to test! šŸ˜€

Perhaps we should add the code from #197 to the documentation on the home page?

Best regards,

-- Harald K

Sounds like a good idea. Though I'm not super familiar with the code and the internals of image processing. I'm going to assume this is good for all formats, save perhaps SVG or others that more heavily rely on "extra syntax" if that makes sense?

KoenDG avatar Jan 29 '20 20:01 KoenDG