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

Fix Ascii IFD reading as TIFF6.0 spec #1451

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

TheZ3ro
Copy link

@TheZ3ro TheZ3ro commented Nov 29, 2024

This PR fixes #187

The TIFF6 specification writes:

Value/Offset
To save time and space the Value Offset contains the Value instead of pointing to
the Value if and only if the Value fits into 4 bytes. If the Value is shorter than 4
bytes, it is left-justified within the 4-byte Value Offset, i.e., stored in the lower-
numbered bytes. Whether the Value fits within 4 bytes is determined by the Type
and Count of the field.

python-docx by default uses the Value/Offset field as a offset for ASCII IFD, but sometime the Value/Offset field could contain directly the Value (if it contains a string with 4 or less characters including the final NULL byte/string terminator)

This is the case for the 2 pictures linked in issue #187 (the Software ASCII field contains 8.3)
image

@TheZ3ro TheZ3ro changed the title fix Ascii IFD reading as TIFF6.0 spec Fix Ascii IFD reading as TIFF6.0 spec Nov 29, 2024
@TheZ3ro TheZ3ro mentioned this pull request Nov 29, 2024
@TheZ3ro
Copy link
Author

TheZ3ro commented Dec 3, 2024

@scanny can you kindly merge this? Thanks!

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

Successfully merging this pull request may close these issues.

add_picture
2 participants