fix tiff parsing in CCITTFactory.extractFromTiff method - #508
Open
valerybokov wants to merge 1 commit into
Open
Conversation
Contributor
Contributor
|
There's a tiff file here: I notice that the error messages in the existing code are switched. |
Contributor
|
I tried with that file yesterday, wasn't successful, and today I think I understand what happens: the two options are not the same. The TIFF option inserts zeroes before the EOL so that the EOL ends at a byte boundary, the PDF option inserts zeroes before the next line so that it starts at a byte boundary. |
Contributor
|
This is getting more and more mysterious. GROUP3OPT_BYTEALIGNED is from a file we copied from the twelvemonkeys project in 2016. However a look at its history shows that this didn't exist. He introduced it in 2020. The constant isn't used anywhere else in the code. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

GROUP3OPT_BYTEALIGNED (bit 3, value 8) is silently ignored.
The tag-292 block never checks val & 8. But COSName.ENCODED_BYTE_ALIGN ("EncodedByteAlign") is a real, wired-up PDF DecodeParms key — CCITTFaxFilter.java:61 reads it (default false) and passes it straight to CCITTFaxDecoderStream. Since extractFromTiff copies the compressed bytes through unmodified, if the source TIFF was Group-3-encoded with byte-aligned rows, the resulting PDF needs /EncodedByteAlign true in its DecodeParms to decode correctly. Currently that flag is never set, so any such TIFF would produce a PDF image that decodes with progressively misaligned rows (visually corrupted/garbled output).