mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-27 10:26:19 +03:00
Simplified code
This commit is contained in:
parent
db20d0f8fe
commit
f42e255206
|
@ -1404,15 +1404,9 @@ class Image:
|
||||||
if 0x0112 not in self._exif:
|
if 0x0112 not in self._exif:
|
||||||
xmp_tags = self.info.get("XML:com.adobe.xmp")
|
xmp_tags = self.info.get("XML:com.adobe.xmp")
|
||||||
if xmp_tags:
|
if xmp_tags:
|
||||||
match = re.search(r'tiff:Orientation="([0-9])"', xmp_tags)
|
match = re.search(r'tiff:Orientation(="|>)([0-9])', xmp_tags)
|
||||||
if match:
|
if match:
|
||||||
self._exif[0x0112] = int(match[1])
|
self._exif[0x0112] = int(match[2])
|
||||||
else:
|
|
||||||
match = re.search(
|
|
||||||
r"<tiff:Orientation>([0-9])</tiff:Orientation>", xmp_tags
|
|
||||||
)
|
|
||||||
if match:
|
|
||||||
self._exif[0x0112] = int(match[1])
|
|
||||||
|
|
||||||
return self._exif
|
return self._exif
|
||||||
|
|
||||||
|
|
|
@ -601,15 +601,12 @@ def exif_transpose(image):
|
||||||
"Raw profile type exif"
|
"Raw profile type exif"
|
||||||
] = transposed_exif.tobytes().hex()
|
] = transposed_exif.tobytes().hex()
|
||||||
elif "XML:com.adobe.xmp" in transposed_image.info:
|
elif "XML:com.adobe.xmp" in transposed_image.info:
|
||||||
transposed_image.info["XML:com.adobe.xmp"] = re.sub(
|
for pattern in (
|
||||||
r'tiff:Orientation="([0-9])"',
|
r'tiff:Orientation="([0-9])"',
|
||||||
"",
|
|
||||||
transposed_image.info["XML:com.adobe.xmp"],
|
|
||||||
)
|
|
||||||
transposed_image.info["XML:com.adobe.xmp"] = re.sub(
|
|
||||||
r"<tiff:Orientation>([0-9])</tiff:Orientation>",
|
r"<tiff:Orientation>([0-9])</tiff:Orientation>",
|
||||||
"",
|
):
|
||||||
transposed_image.info["XML:com.adobe.xmp"],
|
transposed_image.info["XML:com.adobe.xmp"] = re.sub(
|
||||||
|
pattern, "", transposed_image.info["XML:com.adobe.xmp"]
|
||||||
)
|
)
|
||||||
return transposed_image
|
return transposed_image
|
||||||
return image.copy()
|
return image.copy()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user