-
-
Notifications
You must be signed in to change notification settings - Fork 312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"javax.imageio.IIOException: No SOF segment in stream" when using JPEG compression in a TIFF #433
Comments
Hmmmm... Interesting... We never made any promises about partial interop with JAI ImageIO. ;-) But in theory, this should just work. And now that the TIFF plugin is part of the JRE in Java 9+, I think we have to look into it and make sure it does. Which version of the library did you use? The latest release, or the latest master build? Also, did you use the Twelvemonkeys JPEGImageWriter for writing the JPEG data for the TIFF, or the standard Sun/Oracle one? Or does that not matter in this case? I see that the TIFF uses strips, with RowsPerStrip set to 32 (resulting in 4 strips), but does not set the JPEGTables field (optional). The file seems to contain 4 full, valid JPEG streams, so this should be all fine though. I need some time to look into this in detail. -- |
I used release versions: common-image-3.3.2.jar jai-imageio-core-1.4.0.jar (jai community fork) I set a class breakpoint and com.twelvemonkeys.imageio.plugins.jpeg.JPEGImageWriterSpi.createWriterInstance() is called and a com.twelvemonkeys.imageio.plugins.jpeg.JPEGImageWriter object is created. This was indirectly called by com.github.jaiimageio.impl.plugins.tiff.TIFFBaseJPEGCompressor.initJPEGWriter(). Later, com.twelvemonkeys.imageio.plugins.jpeg.JPEGImageWriter.write(IIOMetadata streamMetadata, IIOImage image, ImageWriteParam param) is called 4 times. So that would be a yes on the "did you use the Twelvemonkeys JPEGImageWriter for writing the JPEG data for the TIFF" question. Using or not using the standard jpeg library for writing makes no difference, the file created is the same. This would suggest it is only a reading problem. I extracted the jpeg file from the tiff file (offset 300, len 667) and no problem reading it with twelvemonkeys. Possible idea: Twelvemonkeys JPEGImageReader.readSegments() has "imageInput.seek(0);". Could it be that this is wrong when the jpeg is within the other file? The original JPEGImageReader has checkTablesOnly() which stores the beginning position in imagePositions, which is used later. |
Thanks Tilman!
Yes, this is indeed the bug. For the TwelveMonkeys TIFFImageReader, I always pass the offset JPEG streams as a If I wrap the stream in a Anyway, thanks for reporting and looking further into the issue! -- |
…le stream + embedded case (ie. TIFF).
Fixed in latest master. |
test code:
output:
This happens only if I use the JPEG decoder from here and the jai_imageio.jar from oracle (or the community fork on github). If I use all from oracle or all from twelvemonkeys it works.
test.zip
The text was updated successfully, but these errors were encountered: