mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 01:46:18 +03:00
Tag issues with libtiff -- Need to parse the tuples for the ifd and the im.ifd. getattr + default for the im.ifd instead of silent try/except
This commit is contained in:
parent
8d21ce1df7
commit
32e2f97b21
|
@ -1011,11 +1011,11 @@ def _save(im, fp, filename):
|
|||
_fp = os.dup(fp.fileno())
|
||||
|
||||
blocklist = [STRIPOFFSETS, STRIPBYTECOUNTS, ROWSPERSTRIP, ICCPROFILE] # ICC Profile crashes.
|
||||
atts = dict([(k,v) for (k,(v,)) in ifd.items() if k not in blocklist])
|
||||
try:
|
||||
# pull in more bits from the original file, e.g x,y resolution
|
||||
# so that we can save(load('')) == original file.
|
||||
for k,v in im.ifd.items():
|
||||
atts={}
|
||||
# Merge the ones that we have with (optional) more bits from
|
||||
# the original file, e.g x,y resolution so that we can
|
||||
# save(load('')) == original file.
|
||||
for k,v in itertools.chain(ifd.items(), getattr(im, 'ifd', {}).items()):
|
||||
if k not in atts and k not in blocklist:
|
||||
if type(v[0]) == tuple and len(v) > 1:
|
||||
# A tuple of more than one rational tuples
|
||||
|
@ -1032,12 +1032,9 @@ def _save(im, fp, filename):
|
|||
atts[k] = v[0]
|
||||
continue
|
||||
if type(v) == str:
|
||||
atts[k] = v
|
||||
atts[k] = bytes(v.encode('ascii', 'replace')) + b"\0"
|
||||
continue
|
||||
|
||||
except:
|
||||
# if we don't have an ifd here, just punt.
|
||||
pass
|
||||
if Image.DEBUG:
|
||||
print (atts)
|
||||
|
||||
|
@ -1049,6 +1046,7 @@ def _save(im, fp, filename):
|
|||
rawmode = 'I;16N'
|
||||
|
||||
a = (rawmode, compression, _fp, filename, atts)
|
||||
print (im.mode, compression, a, im.encoderconfig)
|
||||
e = Image._getencoder(im.mode, compression, a, im.encoderconfig)
|
||||
e.setimage(im.im, (0,0)+im.size)
|
||||
while 1:
|
||||
|
|
Loading…
Reference in New Issue
Block a user