From 989e162ff66d74807308f63f1ef0f93be788fd8e Mon Sep 17 00:00:00 2001 From: homm Date: Thu, 12 May 2016 20:28:42 +0300 Subject: [PATCH 1/2] save icc profile from encoderinfo --- PIL/PngImagePlugin.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/PIL/PngImagePlugin.py b/PIL/PngImagePlugin.py index 7734fdeda..649a8446c 100644 --- a/PIL/PngImagePlugin.py +++ b/PIL/PngImagePlugin.py @@ -756,8 +756,8 @@ def _save(im, fp, filename, chunk=putchunk, check=0): for cid, data in info.chunks: chunk(fp, cid, data) - # ICC profile writing support -- 2008-06-06 Florian Hoech - if im.info.get("icc_profile"): + icc = im.encoderinfo.get("icc_profile", im.info.get("icc_profile")) + if icc: # ICC profile # according to PNG spec, the iCCP chunk contains: # Profile name 1-79 bytes (character string) @@ -765,7 +765,7 @@ def _save(im, fp, filename, chunk=putchunk, check=0): # Compression method 1 byte (0) # Compressed profile n bytes (zlib with deflate compression) name = b"ICC Profile" - data = name + b"\0\0" + zlib.compress(im.info["icc_profile"]) + data = name + b"\0\0" + zlib.compress(icc) chunk(fp, b"iCCP", data) ImageFile._save(im, _idat(fp, chunk), From 1a6c6b1250c23993a1b4eb961085dc84c54ad672 Mon Sep 17 00:00:00 2001 From: homm Date: Thu, 12 May 2016 20:28:58 +0300 Subject: [PATCH 2/2] tests for icc profile in png --- Tests/images/icc_profile.png | Bin 0 -> 5788 bytes Tests/test_file_png.py | 40 ++++++++++++++++++++++------------- 2 files changed, 25 insertions(+), 15 deletions(-) create mode 100644 Tests/images/icc_profile.png diff --git a/Tests/images/icc_profile.png b/Tests/images/icc_profile.png new file mode 100644 index 0000000000000000000000000000000000000000..4bf92a1d3859831d1a9e0186fb9566ed74a3fc8b GIT binary patch literal 5788 zcmV;N7Gvp&P)4Tx0C=38mUmQB*%pV-y*Is3k`RiN&}(Q?0!R(LNRcioF$oY#z>okUHbhi# zL{X8Z2r?+(fTKf^u_B6v0a3B*1Q|rsac~qH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