FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Remove zero-byte end padding when parsing any XMP data by radarhere · Pull Request #8171 · python-pillow/Pillow · GitHub

Remove zero-byte end padding when parsing any XMP data - #8171

Merged
hugovk merged 1 commit into
python-pillow:mainfrom
radarhere:xmp
Jun 27, 2024
Merged

Remove zero-byte end padding when parsing any XMP data#8171
hugovk merged 1 commit into
python-pillow:mainfrom
radarhere:xmp

Conversation

Copy link
Copy Markdown
Member

Last year, we received a report of a JPEG image where XMP data was zero-padded at the end. I created a fix for that by adjusting JpegImagePlugin.

Now #8069 (comment) reports that XMP data might also be zero-padded for another format.

So this PR removes zero-byte end padding from XMP data for all formats, not just JPEG.

bigcat88 commented Jun 26, 2024
edited by radarhere
Loading

Copy link
Copy Markdown
Contributor

Yes, with this changes all will be good.

However I found another place in Pillow that failing my tests and I think we need to take a look at that:

ImageOps.py , exif_transpose:

                    exif_image.info["xmp"] = re.sub(
                        pattern.encode(), b"", exif_image.info["xmp"]
                    )

I get an KeyError here, as "xmp" can be not present in exif_image.info keys
Maybe here should be a check for that? Should I create a separate issue for that?

Copy link
Copy Markdown
Contributor

ImageOps.py , exif_transpose:

            elif "XML:com.adobe.xmp" in exif_image.info:
                for pattern in (
                    r'tiff:Orientation="([0-9])"',
                    r"<tiff:Orientation>([0-9])</tiff:Orientation>",
                ):
                    exif_image.info["XML:com.adobe.xmp"] = re.sub(
                        pattern, "", exif_image.info["XML:com.adobe.xmp"]
                    )
            elif "xmp" in exif_image.info:
                for pattern in (
                    r'tiff:Orientation="([0-9])"',
                    r"<tiff:Orientation>([0-9])</tiff:Orientation>",
                ):
                    exif_image.info["xmp"] = re.sub(
                        pattern.encode(), b"", exif_image.info["xmp"]
                    )

imho, this will be the correct code that not fails with exception when "xmp" not in image.info dictionary

Copy link
Copy Markdown
Member Author

I imagine this is where the failure is occurring? For my own clarity, I wouldn't say that pillow-heif is failing, but rather Pillow is failing to handle an image you've constructed in your tests.

But there's no reason that your constructed image isn't perfectly valid, so I've created #8173

By the way, thanks for letting us know about these matters before the release has gone out!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL