mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-06-29 17:33:08 +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())
|
_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])
|
atts={}
|
||||||
try:
|
# Merge the ones that we have with (optional) more bits from
|
||||||
# pull in more bits from the original file, e.g x,y resolution
|
# the original file, e.g x,y resolution so that we can
|
||||||
# so that we can save(load('')) == original file.
|
# save(load('')) == original file.
|
||||||
for k,v in im.ifd.items():
|
for k,v in itertools.chain(ifd.items(), getattr(im, 'ifd', {}).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
|
||||||
|
@ -1032,12 +1032,9 @@ def _save(im, fp, filename):
|
||||||
atts[k] = v[0]
|
atts[k] = v[0]
|
||||||
continue
|
continue
|
||||||
if type(v) == str:
|
if type(v) == str:
|
||||||
atts[k] = v
|
atts[k] = bytes(v.encode('ascii', 'replace')) + b"\0"
|
||||||
continue
|
continue
|
||||||
|
|
||||||
except:
|
|
||||||
# if we don't have an ifd here, just punt.
|
|
||||||
pass
|
|
||||||
if Image.DEBUG:
|
if Image.DEBUG:
|
||||||
print (atts)
|
print (atts)
|
||||||
|
|
||||||
|
@ -1049,6 +1046,7 @@ def _save(im, fp, filename):
|
||||||
rawmode = 'I;16N'
|
rawmode = 'I;16N'
|
||||||
|
|
||||||
a = (rawmode, compression, _fp, filename, atts)
|
a = (rawmode, compression, _fp, filename, atts)
|
||||||
|
print (im.mode, compression, a, im.encoderconfig)
|
||||||
e = Image._getencoder(im.mode, compression, a, im.encoderconfig)
|
e = Image._getencoder(im.mode, compression, a, im.encoderconfig)
|
||||||
e.setimage(im.im, (0,0)+im.size)
|
e.setimage(im.im, (0,0)+im.size)
|
||||||
while 1:
|
while 1:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user