mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 01:16:16 +03:00
Use underscores, not spaces, in TIFF tag kwargs.
kwargs with spaces ("x resolution", "y resolution", "resolution unit" and "date time") are deprecated.
This commit is contained in:
parent
9581da4daa
commit
800480db52
|
@ -1068,31 +1068,25 @@ def _save(im, fp, filename):
|
||||||
if "icc_profile" in im.info:
|
if "icc_profile" in im.info:
|
||||||
ifd[ICCPROFILE] = im.info["icc_profile"]
|
ifd[ICCPROFILE] = im.info["icc_profile"]
|
||||||
|
|
||||||
if "description" in im.encoderinfo:
|
for key, name, cvt in [
|
||||||
ifd[IMAGEDESCRIPTION] = im.encoderinfo["description"]
|
(IMAGEDESCRIPTION, "description", lambda x: x),
|
||||||
if "resolution" in im.encoderinfo:
|
(X_RESOLUTION, "resolution", _cvt_res),
|
||||||
ifd[X_RESOLUTION] = ifd[Y_RESOLUTION] \
|
(Y_RESOLUTION, "resolution", _cvt_res),
|
||||||
= _cvt_res(im.encoderinfo["resolution"])
|
(X_RESOLUTION, "x_resolution", _cvt_res),
|
||||||
if "x resolution" in im.encoderinfo:
|
(Y_RESOLUTION, "y_resolution", _cvt_res),
|
||||||
ifd[X_RESOLUTION] = _cvt_res(im.encoderinfo["x resolution"])
|
(RESOLUTION_UNIT, "resolution_unit",
|
||||||
if "y resolution" in im.encoderinfo:
|
lambda x: {"inch": 2, "cm": 3, "centimeter": 3}.get(x, 1)),
|
||||||
ifd[Y_RESOLUTION] = _cvt_res(im.encoderinfo["y resolution"])
|
(SOFTWARE, "software", lambda x: x),
|
||||||
if "resolution unit" in im.encoderinfo:
|
(DATE_TIME, "date_time", lambda x: x),
|
||||||
unit = im.encoderinfo["resolution unit"]
|
(ARTIST, "artist", lambda x: x),
|
||||||
if unit == "inch":
|
(COPYRIGHT, "copyright", lambda x: x)]:
|
||||||
ifd[RESOLUTION_UNIT] = 2
|
name_with_spaces = name.replace("_", " ")
|
||||||
elif unit == "cm" or unit == "centimeter":
|
if "_" in name and name_with_spaces in im.encoderinfo:
|
||||||
ifd[RESOLUTION_UNIT] = 3
|
warnings.warn("%r is deprecated; use %r instead" %
|
||||||
else:
|
(name_with_spaces, name), DeprecationWarning)
|
||||||
ifd[RESOLUTION_UNIT] = 1
|
ifd[key] = cvt(im.encoderinfo[name.replace("_", " ")])
|
||||||
if "software" in im.encoderinfo:
|
if name in im.encoderinfo:
|
||||||
ifd[SOFTWARE] = im.encoderinfo["software"]
|
ifd[key] = cvt(im.encoderinfo[name])
|
||||||
if "date time" in im.encoderinfo:
|
|
||||||
ifd[DATE_TIME] = im.encoderinfo["date time"]
|
|
||||||
if "artist" in im.encoderinfo:
|
|
||||||
ifd[ARTIST] = im.encoderinfo["artist"]
|
|
||||||
if "copyright" in im.encoderinfo:
|
|
||||||
ifd[COPYRIGHT] = im.encoderinfo["copyright"]
|
|
||||||
|
|
||||||
dpi = im.encoderinfo.get("dpi")
|
dpi = im.encoderinfo.get("dpi")
|
||||||
if dpi:
|
if dpi:
|
||||||
|
|
|
@ -470,21 +470,21 @@ These arguments to set the tiff header fields are an alternative to using the ge
|
||||||
|
|
||||||
**software**
|
**software**
|
||||||
|
|
||||||
**date time**
|
**date_time**
|
||||||
|
|
||||||
**artist**
|
**artist**
|
||||||
|
|
||||||
**copyright**
|
**copyright**
|
||||||
Strings
|
Strings
|
||||||
|
|
||||||
**resolution unit**
|
**resolution_unit**
|
||||||
A string of "inch", "centimeter" or "cm"
|
A string of "inch", "centimeter" or "cm"
|
||||||
|
|
||||||
**resolution**
|
**resolution**
|
||||||
|
|
||||||
**x resolution**
|
**x_resolution**
|
||||||
|
|
||||||
**y resolution**
|
**y_resolution**
|
||||||
|
|
||||||
**dpi**
|
**dpi**
|
||||||
Either a Float, Integer, or 2 tuple of (numerator,
|
Either a Float, Integer, or 2 tuple of (numerator,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user