Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
aba7a34
Fix setting of TIFF ExtraSamples tag.
anntzer Dec 28, 2014
974bcc0
Major rewrite of TIFF ImageFileDirectory.
anntzer Dec 29, 2014
56a3f0f
Fix EXIF support.
anntzer Dec 30, 2014
d5b46dc
Fix MPO support, and Python2.6 support.
anntzer Jan 14, 2015
38f7e23
Include tests of #1113.
anntzer Feb 26, 2015
93abbd0
Restore legacy TIFF API.
anntzer Mar 1, 2015
6309bfe
Support too long ExtraSamples.
anntzer Jun 16, 2015
1b9b374
Reorder OPEN_INFO to cover both endiannesses.
anntzer Jun 16, 2015
ba7b8d1
Fail on invalid EXIF, reverting ed2cca1.
anntzer Jun 29, 2015
c113e8f
libtiff's rational precision is limited to C floats.
anntzer Jul 1, 2015
0c94291
fixed the rebase
wiredfool Sep 10, 2015
9bb4c51
module level default api level
wiredfool Sep 10, 2015
47a963c
Legacy/versioned interface
wiredfool Sep 11, 2015
5f9fff0
Restoring bad exif handling
wiredfool Sep 11, 2015
426c9d8
test failing update
wiredfool Sep 11, 2015
b1fdff4
In a twisty maze of bytes, text and arbitrary metadata, py2 and py3. …
wiredfool Sep 11, 2015
0c35194
rewrite of #1416 working
wiredfool Sep 12, 2015
1569728
missed a set of _v2 versioning
wiredfool Sep 13, 2015
a9396ab
convert load_* functions to pure functions with no state
wiredfool Sep 13, 2015
e1236d7
v1/v2 tag storage in IFD, legacy_api as a parameter to _saveitem, sav…
wiredfool Sep 13, 2015
2636679
updating tests for legacy_api api change
wiredfool Sep 13, 2015
bb75b2d
Added doc comment
wiredfool Sep 13, 2015
ca24a44
Rewrap intelligently
wiredfool Sep 13, 2015
f3ab9b9
temp removing segfaulting test on travis
wiredfool Sep 13, 2015
4596df4
Versioned interface for TiffTags
wiredfool Sep 13, 2015
70977bc
Got the order of the enums wrong
wiredfool Sep 13, 2015
86bda9a
Legacy tifftags
wiredfool Sep 13, 2015
c2818ee
Add versioned api to tests
wiredfool Sep 13, 2015
b56d5ca
Added indicator for multipage tiffs
wiredfool Sep 13, 2015
05348d4
Reenabling failing/crashing tests, with fixes
wiredfool Sep 14, 2015
4adbc97
Reorder load_* parameters to pass master tests
wiredfool Sep 14, 2015
9286c9e
Reenabling and fixing the former test_xyres_tiff test for integer res…
wiredfool Sep 14, 2015
1614f2f
Documentation for IFD Changes
wiredfool Sep 14, 2015
e4f9b69
Doc syntax error
wiredfool Sep 14, 2015
63f5f68
unused imports
homm Sep 14, 2015
9930b05
fix tiff exif loading in case when file is empty or ended
homm Sep 15, 2015
0f87b1f
suppress and check warning during tests
homm Sep 14, 2015
b1066bd
Merge pull request #3 from uploadcare/tiff-ifd-tests
wiredfool Sep 15, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions PIL/IptcImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def getiptcinfo(im):
while app[offset:offset+4] == b"8BIM":
offset += 4
# resource code
code = JpegImagePlugin.i16(app, offset)
code = i16(app, offset)
offset += 2
# resource name (usually empty)
name_len = i8(app[offset])
Expand All @@ -226,7 +226,7 @@ def getiptcinfo(im):
if offset & 1:
offset += 1
# resource data block
size = JpegImagePlugin.i32(app, offset)
size = i32(app, offset)
offset += 4
if code == 0x0404:
# 0x0404 contains IPTC/NAA data
Expand Down
41 changes: 14 additions & 27 deletions PIL/JpegImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import struct
import io
import warnings
from struct import unpack
from struct import unpack_from
from PIL import Image, ImageFile, TiffImagePlugin, _binary
from PIL.JpegPresets import presets
from PIL._util import isStringType
Expand Down Expand Up @@ -394,13 +394,6 @@ def _getmp(self):
return _getmp(self)


def _fixup(value):
# Helper function for _getexif() and _getmp()
if len(value) == 1:
return value[0]
return value


def _getexif(self):
# Extract EXIF information. This method is highly experimental,
# and is likely to be replaced with something better in a future
Expand All @@ -414,12 +407,10 @@ def _getexif(self):
return None
file = io.BytesIO(data[6:])
head = file.read(8)
exif = {}
# process dictionary
info = TiffImagePlugin.ImageFileDirectory(head)
info = TiffImagePlugin.ImageFileDirectory_v2(head)
info.load(file)
for key, value in info.items():
exif[key] = _fixup(value)
exif = dict(info)
# get exif extension
try:
# exif field 0x8769 is an offset pointer to the location
Expand All @@ -429,24 +420,21 @@ def _getexif(self):
except (KeyError, TypeError):
pass
else:
info = TiffImagePlugin.ImageFileDirectory(head)
info = TiffImagePlugin.ImageFileDirectory_v2(head)
info.load(file)
for key, value in info.items():
exif[key] = _fixup(value)
exif.update(info)
# get gpsinfo extension
try:
# exif field 0x8825 is an offset pointer to the location
# of the nested embedded gps exif ifd.
# It should be a long, but may be corrupted.
file.seek(exif[0x8825])
file.seek(exif[0x8825])
except (KeyError, TypeError):
pass
else:
info = TiffImagePlugin.ImageFileDirectory(head)
info = TiffImagePlugin.ImageFileDirectory_v2(head)
info.load(file)
exif[0x8825] = gps = {}
for key, value in info.items():
gps[key] = _fixup(value)
exif[0x8825] = dict(info)
return exif


Expand All @@ -464,23 +452,22 @@ def _getmp(self):
file_contents = io.BytesIO(data)
head = file_contents.read(8)
endianness = '>' if head[:4] == b'\x4d\x4d\x00\x2a' else '<'
mp = {}
# process dictionary
info = TiffImagePlugin.ImageFileDirectory(head)
info = TiffImagePlugin.ImageFileDirectory_v2(head)
info.load(file_contents)
for key, value in info.items():
mp[key] = _fixup(value)
mp = dict(info)
# it's an error not to have a number of images
try:
quant = mp[0xB001]
except KeyError:
raise SyntaxError("malformed MP Index (no number of images)")
# get MP entries
mpentries = []
try:
mpentries = []
rawmpentries = mp[0xB002]
for entrynum in range(0, quant):
rawmpentry = mp[0xB002][entrynum * 16:(entrynum + 1) * 16]
unpackedentry = unpack('{0}LLLHH'.format(endianness), rawmpentry)
unpackedentry = unpack_from(
'{0}LLLHH'.format(endianness), rawmpentries, entrynum * 16)
labels = ('Attribute', 'Size', 'DataOffset', 'EntryNo1',
'EntryNo2')
mpentry = dict(zip(labels, unpackedentry))
Expand Down
1 change: 0 additions & 1 deletion PIL/PixarImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
# helpers

i16 = _binary.i16le
i32 = _binary.i32le


##
Expand Down
1 change: 0 additions & 1 deletion PIL/SgiImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

i8 = _binary.i8
i16 = _binary.i16be
i32 = _binary.i32be


def _accept(prefix):
Expand Down
1 change: 0 additions & 1 deletion PIL/SunImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

__version__ = "0.3"

i16 = _binary.i16be
i32 = _binary.i32be


Expand Down
1 change: 0 additions & 1 deletion PIL/TgaImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

i8 = _binary.i8
i16 = _binary.i16le
i32 = _binary.i32le


MODES = {
Expand Down
Loading