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

Re-encoding a CCITT compressed TIFF may cause ClassCastException #312

Closed
haraldk opened this issue Jan 10, 2017 · 1 comment
Closed

Re-encoding a CCITT compressed TIFF may cause ClassCastException #312

haraldk opened this issue Jan 10, 2017 · 1 comment
Assignees
Milestone

Comments

@haraldk
Copy link
Owner

haraldk commented Jan 10, 2017

In the case of re-encoding a CCITT compressed TIFF, with metadata from the original, the G3/G4 options may not be a long value as the writer expects, thus causing a ClassCastException.

See #310 for background and sample images.

Full stack trace:

Exception in thread "main" java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Long
at com.twelvemonkeys.imageio.plugins.tiff.TIFFImageWriter.createCompressorStream(TIFFImageWriter.java:578)
at com.twelvemonkeys.imageio.plugins.tiff.TIFFImageWriter.writePage(TIFFImageWriter.java:430)
at com.twelvemonkeys.imageio.plugins.tiff.TIFFImageWriter.writeToSequence(TIFFImageWriter.java:975)

Easily fixed by changing the line in question to:

option = ((Number) entries.get(compression == TIFFExtension.COMPRESSION_CCITT_T4 ? TIFF.TAG_GROUP3OPTIONS : TIFF.TAG_GROUP4OPTIONS).getValue()).longValue();
@haraldk
Copy link
Owner Author

haraldk commented Jan 18, 2017

Fixed in 6ea1ea8.

@haraldk haraldk closed this as completed Jan 18, 2017
haraldk added a commit that referenced this issue Feb 2, 2017
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

1 participant