Skip to content

Conversation

@radarhere
Copy link
Member

Alternative to #8316

For this TiffImagePlugin fixIFD() code

if is_local:
self._fixOffsets(count, field_size)
self.f.seek(cur_pos + 4)
else:
self.f.seek(offset)
self._fixOffsets(count, field_size)
self.f.seek(cur_pos)

the original PR suggests catching RunTimeErrors ("not implemented", "wrote only {bytes_written} bytes but wanted {expected}" or "offset is not supported") and re-raising it with tag info appended to the error message.

I think the way this is done in the rest of TiffImagePlugin is to use logger.debug().

tagname = TiffTags.lookup(tag, self.group).name
typname = "ifd" if is_ifd else TYPES.get(typ, "unknown")
msg = f"save: {tagname} ({tag}) - type: {typname} ({typ})"
msg += " - value: " + (
"<table: %d bytes>" % len(data) if len(data) >= 16 else str(values)
)
logger.debug(msg)

So this PR uses logger.debug() instead.

Co-authored-by: Hugo van Kemenade <[email protected]>
@hugovk hugovk merged commit bff83cf into python-pillow:main Jan 16, 2025
51 of 53 checks passed
@radarhere radarhere deleted the fixifd branch January 16, 2025 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants