mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 01:46:18 +03:00
Merge branch 'master' of github.com:python-imaging/Pillow
This commit is contained in:
commit
c6b41f27a1
12
PIL/Image.py
12
PIL/Image.py
|
@ -224,6 +224,18 @@ _MODE_CONV = {
|
|||
"RGBA": ('|u1', 4),
|
||||
"CMYK": ('|u1', 4),
|
||||
"YCbCr": ('|u1', 3),
|
||||
"I;16": ('=u2', None),
|
||||
"I;16B": ('>u2', None),
|
||||
"I;16L": ('<u2', None),
|
||||
"I;16S": ('=i2', None),
|
||||
"I;16BS": ('>i2', None),
|
||||
"I;16LS": ('<i2', None),
|
||||
"I;32": ('=u4', None),
|
||||
"I;32B": ('>u4', None),
|
||||
"I;32L": ('<u4', None),
|
||||
"I;32S": ('=i4', None),
|
||||
"I;32BS": ('>i4', None),
|
||||
"I;32LS": ('<i4', None),
|
||||
}
|
||||
|
||||
def _conv_type_shape(im):
|
||||
|
|
|
@ -359,51 +359,55 @@ class JpegImageFile(ImageFile.ImageFile):
|
|||
self.tile = []
|
||||
|
||||
def _getexif(self):
|
||||
# Extract EXIF information. This method is highly experimental,
|
||||
# and is likely to be replaced with something better in a future
|
||||
# version.
|
||||
from PIL import TiffImagePlugin
|
||||
import io
|
||||
def fixup(value):
|
||||
if len(value) == 1:
|
||||
return value[0]
|
||||
return value
|
||||
# The EXIF record consists of a TIFF file embedded in a JPEG
|
||||
# application marker (!).
|
||||
try:
|
||||
data = self.info["exif"]
|
||||
except KeyError:
|
||||
return None
|
||||
file = io.BytesIO(data[6:])
|
||||
head = file.read(8)
|
||||
exif = {}
|
||||
# process dictionary
|
||||
return _getexif(self)
|
||||
|
||||
|
||||
def _getexif(self):
|
||||
# Extract EXIF information. This method is highly experimental,
|
||||
# and is likely to be replaced with something better in a future
|
||||
# version.
|
||||
from PIL import TiffImagePlugin
|
||||
import io
|
||||
def fixup(value):
|
||||
if len(value) == 1:
|
||||
return value[0]
|
||||
return value
|
||||
# The EXIF record consists of a TIFF file embedded in a JPEG
|
||||
# application marker (!).
|
||||
try:
|
||||
data = self.info["exif"]
|
||||
except KeyError:
|
||||
return None
|
||||
file = io.BytesIO(data[6:])
|
||||
head = file.read(8)
|
||||
exif = {}
|
||||
# process dictionary
|
||||
info = TiffImagePlugin.ImageFileDirectory(head)
|
||||
info.load(file)
|
||||
for key, value in info.items():
|
||||
exif[key] = fixup(value)
|
||||
# get exif extension
|
||||
try:
|
||||
file.seek(exif[0x8769])
|
||||
except KeyError:
|
||||
pass
|
||||
else:
|
||||
info = TiffImagePlugin.ImageFileDirectory(head)
|
||||
info.load(file)
|
||||
for key, value in info.items():
|
||||
exif[key] = fixup(value)
|
||||
# get exif extension
|
||||
try:
|
||||
file.seek(exif[0x8769])
|
||||
except KeyError:
|
||||
pass
|
||||
else:
|
||||
info = TiffImagePlugin.ImageFileDirectory(head)
|
||||
info.load(file)
|
||||
for key, value in info.items():
|
||||
exif[key] = fixup(value)
|
||||
# get gpsinfo extension
|
||||
try:
|
||||
file.seek(exif[0x8825])
|
||||
except KeyError:
|
||||
pass
|
||||
else:
|
||||
info = TiffImagePlugin.ImageFileDirectory(head)
|
||||
info.load(file)
|
||||
exif[0x8825] = gps = {}
|
||||
for key, value in info.items():
|
||||
gps[key] = fixup(value)
|
||||
return exif
|
||||
# get gpsinfo extension
|
||||
try:
|
||||
file.seek(exif[0x8825])
|
||||
except KeyError:
|
||||
pass
|
||||
else:
|
||||
info = TiffImagePlugin.ImageFileDirectory(head)
|
||||
info.load(file)
|
||||
exif[0x8825] = gps = {}
|
||||
for key, value in info.items():
|
||||
gps[key] = fixup(value)
|
||||
return exif
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# stuff to save JPEG files
|
||||
|
|
|
@ -39,8 +39,8 @@ class WebPImageFile(ImageFile.ImageFile):
|
|||
self.tile = [("raw", (0, 0) + self.size, 0, self.mode)]
|
||||
|
||||
def _getexif(self):
|
||||
from PIL.JpegImagePlugin import JpegImageFile
|
||||
return JpegImageFile._getexif.im_func(self)
|
||||
from PIL.JpegImagePlugin import _getexif
|
||||
return _getexif(self)
|
||||
|
||||
|
||||
def _save(im, fp, filename):
|
||||
|
|
Loading…
Reference in New Issue
Block a user