mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-10 16:22:22 +03:00
Proper handling of both IFDs for libtiff usage
This commit is contained in:
parent
2188cf2baf
commit
0204733fd6
|
@ -1071,11 +1071,13 @@ def _save(im, fp, filename):
|
||||||
_fp = os.dup(fp.fileno())
|
_fp = os.dup(fp.fileno())
|
||||||
|
|
||||||
blocklist = [STRIPOFFSETS, STRIPBYTECOUNTS, ROWSPERSTRIP, ICCPROFILE] # ICC Profile crashes.
|
blocklist = [STRIPOFFSETS, STRIPBYTECOUNTS, ROWSPERSTRIP, ICCPROFILE] # ICC Profile crashes.
|
||||||
atts = dict([(k,v) for (k,(v,)) in ifd.items() if k not in blocklist])
|
|
||||||
|
items = itertools.chain(getattr(im, 'ifd', {}).items(), ifd.items())
|
||||||
|
atts = {}
|
||||||
try:
|
try:
|
||||||
# pull in more bits from the original file, e.g x,y resolution
|
# pull in more bits from the original file, e.g x,y resolution
|
||||||
# so that we can save(load('')) == original file.
|
# so that we can save(load('')) == original file.
|
||||||
for k,v in im.ifd.items():
|
for k,v in items:
|
||||||
if k not in atts and k not in blocklist:
|
if k not in atts and k not in blocklist:
|
||||||
if type(v[0]) == tuple and len(v) > 1:
|
if type(v[0]) == tuple and len(v) > 1:
|
||||||
# A tuple of more than one rational tuples
|
# A tuple of more than one rational tuples
|
||||||
|
@ -1094,9 +1096,15 @@ def _save(im, fp, filename):
|
||||||
if type(v) == str:
|
if type(v) == str:
|
||||||
atts[k] = v
|
atts[k] = v
|
||||||
continue
|
continue
|
||||||
|
if type(v) == unicode:
|
||||||
|
atts[k] = v.encode('ascii', errors='ignore')
|
||||||
|
continue
|
||||||
|
|
||||||
except:
|
except Exception, msg:
|
||||||
# if we don't have an ifd here, just punt.
|
# if we don't have an ifd here, just punt.
|
||||||
|
if Image.DEBUG:
|
||||||
|
print (msg)
|
||||||
|
#raise msg
|
||||||
pass
|
pass
|
||||||
if Image.DEBUG:
|
if Image.DEBUG:
|
||||||
print (atts)
|
print (atts)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user