Skip to content
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

TIF: read after save fails with EOFException #241

Closed
THausherr opened this issue May 9, 2016 · 6 comments
Closed

TIF: read after save fails with EOFException #241

THausherr opened this issue May 9, 2016 · 6 comments
Milestone

Comments

@THausherr
Copy link

THausherr commented May 9, 2016

I am unable to read the file from #237 after saving it as a TIF:

        BufferedImage bim = ImageIO.read(new File("XXXX\\badccittstream.tif"));
        ImageIO.write(bim, "tif", new File("XXX\\badccittstream-saved.tif"));
        ImageIO.read(new File("XXXX\\badccittstream-saved.tif"));

badccittstream.zip

Exception in thread "main" java.io.EOFException
    at javax.imageio.stream.ImageInputStreamImpl.readFully(ImageInputStreamImpl.java:353)
    at javax.imageio.stream.ImageInputStreamImpl.readFully(ImageInputStreamImpl.java:361)
    at com.twelvemonkeys.imageio.metadata.exif.EXIFReader.readValue(EXIFReader.java:328)
    at com.twelvemonkeys.image io.metadata.exif.EXIFReader.readValueAt(EXIFReader.java:287)
    at com.twelvemonkeys.imageio.metadata.exif.EXIFReader.readEntry(EXIFReader.java:277)
    at com.twelvemonkeys.imageio.metadata.exif.EXIFReader.readDirectory(EXIFReader.java:109)
    at com.twelvemonkeys.imageio.metadata.exif.EXIFReader.readDirectory(EXIFReader.java:133)
    at com.twelvemonkeys.imageio.metadata.exif.EXIFReader.read(EXIFReader.java:87)
    at com.twelvemonkeys.imageio.plugins.tiff.TIFFImageReader.readMetadata(TIFFImageReader.java:171)
    at com.twelvemonkeys.imageio.plugins.tiff.TIFFImageReader.readIFD(TIFFImageReader.java:252)
    at com.twelvemonkeys.imageio.plugins.tiff.TIFFImageReader.read(TIFFImageReader.java:715)
    at javax.imageio.ImageIO.read(ImageIO.java:1448)
    at javax.imageio.ImageIO.read(ImageIO.java:1308)

The saved file cannot be displayed with IrfanView too.

@THausherr
Copy link
Author

I just see that there was a remark in #237 "I suppose the Encoder is also affected" (I didn't get that mail).

@Schmidor
Copy link
Contributor

Schmidor commented May 9, 2016

I've looked into that and was convinced that the encoder didn't need the additional array length.
I have to look into that, but as ImageIO.write doesn't conserve meta data it could be that the writer is writing uncompressed and you're running into #229
This is what I encountered at writing #239

@Schmidor
Copy link
Contributor

Schmidor commented May 9, 2016

Indeed the writer defaults to uncompressed, if no compression mode is set by metadata or ImageWriterParams. So this is a duplicate of #229

@haraldk
Copy link
Owner

haraldk commented May 9, 2016

I was just about to comment on that, but you beat me to it.

Yes, I believe so too.

Actually, it could be that we should use different defaults for compression depending on input image (b/w -> CCITT, uint RGB/Gray/CMYK -> LZW/PackBits, etc), but I think the current implementation will be fastest and most compatible (we should probably do the same thing as the JAI TIFFImageWriter does), at the expense of larger file sizes. But that is a different issue.

Harald K

@haraldk
Copy link
Owner

haraldk commented Jul 1, 2016

I believe this is fixed in 04a3915.

This will be part of the 3.3 release. Working hard on squashing the last known bugs....

Best regards,

Harald K

@haraldk haraldk closed this as completed Jul 1, 2016
@haraldk
Copy link
Owner

haraldk commented Nov 3, 2016

@THausherr This bugfix is now included in the official 3.3 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants