mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-03 21:24:31 +03:00
Use ExifTags
This commit is contained in:
parent
bcb8dfc2fa
commit
fe8599c5d6
|
@ -1418,12 +1418,12 @@ class Image:
|
||||||
self._exif.load(exif_info)
|
self._exif.load(exif_info)
|
||||||
|
|
||||||
# XMP tags
|
# XMP tags
|
||||||
if 0x0112 not in self._exif:
|
if ExifTags.Base.Orientation 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[2])
|
self._exif[ExifTags.Base.Orientation] = int(match[2])
|
||||||
|
|
||||||
return self._exif
|
return self._exif
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ import functools
|
||||||
import operator
|
import operator
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from . import Image, ImagePalette
|
from . import ExifTags, Image, ImagePalette
|
||||||
|
|
||||||
#
|
#
|
||||||
# helpers
|
# helpers
|
||||||
|
@ -589,7 +589,7 @@ def exif_transpose(image, inPlace=False):
|
||||||
image will be returned.
|
image will be returned.
|
||||||
"""
|
"""
|
||||||
image_exif = image.getexif()
|
image_exif = image.getexif()
|
||||||
orientation = image_exif.get(0x0112)
|
orientation = image_exif.get(ExifTags.Base.Orientation)
|
||||||
method = {
|
method = {
|
||||||
2: Image.Transpose.FLIP_LEFT_RIGHT,
|
2: Image.Transpose.FLIP_LEFT_RIGHT,
|
||||||
3: Image.Transpose.ROTATE_180,
|
3: Image.Transpose.ROTATE_180,
|
||||||
|
@ -608,8 +608,8 @@ def exif_transpose(image, inPlace=False):
|
||||||
exif_image = image if inPlace else transposed_image
|
exif_image = image if inPlace else transposed_image
|
||||||
|
|
||||||
exif = exif_image.getexif()
|
exif = exif_image.getexif()
|
||||||
if 0x0112 in exif:
|
if ExifTags.Base.Orientation in exif:
|
||||||
del exif[0x0112]
|
del exif[ExifTags.Base.Orientation]
|
||||||
if "exif" in exif_image.info:
|
if "exif" in exif_image.info:
|
||||||
exif_image.info["exif"] = exif.tobytes()
|
exif_image.info["exif"] = exif.tobytes()
|
||||||
elif "Raw profile type exif" in exif_image.info:
|
elif "Raw profile type exif" in exif_image.info:
|
||||||
|
|
|
@ -49,7 +49,7 @@ from collections.abc import MutableMapping
|
||||||
from fractions import Fraction
|
from fractions import Fraction
|
||||||
from numbers import Number, Rational
|
from numbers import Number, Rational
|
||||||
|
|
||||||
from . import Image, ImageFile, ImageOps, ImagePalette, TiffTags
|
from . import ExifTags, Image, ImageFile, ImageOps, ImagePalette, TiffTags
|
||||||
from ._binary import i16be as i16
|
from ._binary import i16be as i16
|
||||||
from ._binary import i32be as i32
|
from ._binary import i32be as i32
|
||||||
from ._binary import o8
|
from ._binary import o8
|
||||||
|
@ -1183,7 +1183,7 @@ class TiffImageFile(ImageFile.ImageFile):
|
||||||
:returns: Photoshop "Image Resource Blocks" in a dictionary.
|
:returns: Photoshop "Image Resource Blocks" in a dictionary.
|
||||||
"""
|
"""
|
||||||
blocks = {}
|
blocks = {}
|
||||||
val = self.tag_v2.get(0x8649)
|
val = self.tag_v2.get(ExifTags.Base.ImageResources)
|
||||||
if val:
|
if val:
|
||||||
while val[:4] == b"8BIM":
|
while val[:4] == b"8BIM":
|
||||||
id = i16(val[4:6])
|
id = i16(val[4:6])
|
||||||
|
@ -1548,7 +1548,7 @@ class TiffImageFile(ImageFile.ImageFile):
|
||||||
palette = [o8(b // 256) for b in self.tag_v2[COLORMAP]]
|
palette = [o8(b // 256) for b in self.tag_v2[COLORMAP]]
|
||||||
self.palette = ImagePalette.raw("RGB;L", b"".join(palette))
|
self.palette = ImagePalette.raw("RGB;L", b"".join(palette))
|
||||||
|
|
||||||
self._tile_orientation = self.tag_v2.get(0x0112)
|
self._tile_orientation = self.tag_v2.get(ExifTags.Base.Orientation)
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in New Issue
Block a user