mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-24 08:14:10 +03:00
final pass through atts: handling single rational tuple, using isStringType, flattening from single element tuple to string or int
This commit is contained in:
parent
6357b4707c
commit
6a0516d2c9
|
@ -46,6 +46,7 @@ __version__ = "1.3.5"
|
||||||
from PIL import Image, ImageFile
|
from PIL import Image, ImageFile
|
||||||
from PIL import ImagePalette
|
from PIL import ImagePalette
|
||||||
from PIL import _binary
|
from PIL import _binary
|
||||||
|
from PIL._util import isStringType
|
||||||
|
|
||||||
import warnings
|
import warnings
|
||||||
import array, sys
|
import array, sys
|
||||||
|
@ -1027,13 +1028,25 @@ def _save(im, fp, filename):
|
||||||
# flatten to floats, following tiffcp.c->cpTag->TIFF_RATIONAL
|
# flatten to floats, following tiffcp.c->cpTag->TIFF_RATIONAL
|
||||||
atts[k] = float(v[0][0])/float(v[0][1])
|
atts[k] = float(v[0][0])/float(v[0][1])
|
||||||
continue
|
continue
|
||||||
if type(v) == tuple and len(v) == 1:
|
if type(v) == tuple and len(v) > 2:
|
||||||
# int or similar
|
# List of ints?
|
||||||
atts[k] = v[0]
|
# BitsPerSample is one example, I get (8,8,8)
|
||||||
|
# UNDONE
|
||||||
continue
|
continue
|
||||||
if type(v) == str:
|
if type(v) == tuple and len(v) == 2:
|
||||||
|
# one rational tuple
|
||||||
|
# flatten to float, following tiffcp.c->cpTag->TIFF_RATIONAL
|
||||||
|
atts[k] = float(v[0])/float(v[1])
|
||||||
|
continue
|
||||||
|
if type(v) == tuple and len(v) == 1:
|
||||||
|
v = v[0]
|
||||||
|
# drop through
|
||||||
|
if isStringType(v):
|
||||||
atts[k] = bytes(v.encode('ascii', 'replace')) + b"\0"
|
atts[k] = bytes(v.encode('ascii', 'replace')) + b"\0"
|
||||||
continue
|
continue
|
||||||
|
else:
|
||||||
|
# int or similar
|
||||||
|
atts[k] = v
|
||||||
|
|
||||||
if Image.DEBUG:
|
if Image.DEBUG:
|
||||||
print (atts)
|
print (atts)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user