From 41b58f4b1646a6fc7c3263225a231370134ffff3 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Wed, 30 Jun 2021 11:20:55 +1000 Subject: [PATCH] Replaced xml.etree.ElementTree with re --- src/PIL/Image.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/PIL/Image.py b/src/PIL/Image.py index a549a5bb0..587d44e97 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -31,6 +31,7 @@ import logging import math import numbers import os +import re import struct import sys import tempfile @@ -1381,15 +1382,9 @@ class Image: if 0x0112 not in self._exif: xmp_tags = self.info.get("XML:com.adobe.xmp") if xmp_tags: - xmp = self._getxmp(xmp_tags) - if ( - "xmpmeta" in xmp - and "RDF" in xmp["xmpmeta"] - and "Description" in xmp["xmpmeta"]["RDF"] - ): - description = xmp["xmpmeta"]["RDF"]["Description"] - if "Orientation" in description: - self._exif[0x0112] = int(description["Orientation"]) + match = re.search(r'tiff:Orientation="([0-9])"', xmp_tags) + if match: + self._exif[0x0112] = int(match[1]) return self._exif