From bccc26057dd47c80be4a2448494d8b6d9a3880c3 Mon Sep 17 00:00:00 2001 From: dennis Date: Fri, 22 Sep 2023 13:30:20 +0800 Subject: [PATCH] JpegImagePlugin.py fix to resolve issue with xmp meta having trailing 0x00 byte I faced the issue with files having trailing 0x00 in xmp meta information. The files was originally generated with Canon Digital Photo Professional and later edited in MacOs Preview to add image description to the meta information. I haven't investigated which program exactly added trailing zero byte but fix is dealing with it fine --- src/PIL/JpegImagePlugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PIL/JpegImagePlugin.py b/src/PIL/JpegImagePlugin.py index 74130854fbc..978277b5473 100644 --- a/src/PIL/JpegImagePlugin.py +++ b/src/PIL/JpegImagePlugin.py @@ -496,7 +496,7 @@ def getxmp(self): for segment, content in self.applist: if segment == "APP1": - marker, xmp_tags = content.rsplit(b"\x00", 1) + marker, xmp_tags = content.strip(b"\x00").rsplit(b"\x00", 1) if marker == b"http://ns.adobe.com/xap/1.0/": return self._getxmp(xmp_tags) return {}