From 0348fcac51046bc369da3003e70f2790586315d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Reni=C3=A9?= Date: Sun, 19 Jan 2014 16:40:39 +0100 Subject: [PATCH 1/4] Fix crash on save when icc_profile is None --- PIL/PngImagePlugin.py | 2 +- Tests/images/icc_profile_none.png | Bin 0 -> 4128 bytes Tests/test_file_png.py | 7 +++++++ 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 Tests/images/icc_profile_none.png diff --git a/PIL/PngImagePlugin.py b/PIL/PngImagePlugin.py index 7028083d7..f3738bd24 100644 --- a/PIL/PngImagePlugin.py +++ b/PIL/PngImagePlugin.py @@ -618,7 +618,7 @@ def _save(im, fp, filename, chunk=putchunk, check=0): name = p.tags.desc.get("ASCII", p.tags.desc.get("Unicode", p.tags.desc.get("Macintosh", p.tags.desc.get("en", {}).get("US", "ICC Profile")))).encode("latin1", "replace")[:79] except ImportError: name = b"ICC Profile" - data = name + b"\0\0" + zlib.compress(im.info["icc_profile"]) + data = name or b'ICC Profile' + b"\0\0" + zlib.compress(im.info["icc_profile"]) chunk(fp, b"iCCP", data) ImageFile._save(im, _idat(fp, chunk), [("zip", (0,0)+im.size, 0, rawmode)]) diff --git a/Tests/images/icc_profile_none.png b/Tests/images/icc_profile_none.png new file mode 100644 index 0000000000000000000000000000000000000000..9ecff3a97b8eb78026c4ccf27b72039b52311f1e GIT binary patch literal 4128 zcmV+*5Z~{KP)4Tx0F9H&YZO@&hrjCFppYO8w69(amsv=VB$N*{B0kbdY@)Gk%0!bONT>RC zcbS{&np@Rz6cNeBrOq&W@v(5>AK=1;E8Qp&d?AQ?6-5->sI-gfbXV|sR$u+jxxaJH zEiQE0#URir33GmAoLp8;PEE@d&q%SJE;4i#-7pv|6vhCGL7@32K0d($c-Z&-{7<8+ z6uNU@t%TJ3k_uhu_zcu4lT*_mG>|?S1rdmIK-$Fm|3G>s=IcP(j5|XhZUL*@z(gSK z0RwKeSb|Og^i~ozGYOv4b+&d|CO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_V{|Od^Q9CB0fphmnEzs(i2s38j`1Zz}9a$ zjC*xAJR>(z`sf+b<}QZa*IOZbvmNhB^rSDmdtnRGNi$c#^io$=%3$t*ML}v>g9Qdm zJXzez+=rB`JF~9kW7#uiMcFv!Ewx(195z?~ngD`JeR#EAu`6>C`60)VA9ez5BLav^ z65i>v{_M?rp}c+z_8~hcvK Date: Sun, 19 Jan 2014 19:09:40 +0100 Subject: [PATCH 2/4] Cleanup handling of ICC profile, more extensive testing --- PIL/PngImagePlugin.py | 11 +++-------- Tests/images/trollface.png | Bin 0 -> 13871 bytes Tests/test_file_png.py | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 8 deletions(-) create mode 100644 Tests/images/trollface.png diff --git a/PIL/PngImagePlugin.py b/PIL/PngImagePlugin.py index f3738bd24..a6038d9f2 100644 --- a/PIL/PngImagePlugin.py +++ b/PIL/PngImagePlugin.py @@ -605,20 +605,15 @@ def _save(im, fp, filename, chunk=putchunk, check=0): chunk(fp, cid, data) # ICC profile writing support -- 2008-06-06 Florian Hoech - if "icc_profile" in im.info: + if im.info.get("icc_profile"): # ICC profile # according to PNG spec, the iCCP chunk contains: # Profile name 1-79 bytes (character string) # Null separator 1 byte (null character) # Compression method 1 byte (0) # Compressed profile n bytes (zlib with deflate compression) - try: - import ICCProfile - p = ICCProfile.ICCProfile(im.info["icc_profile"]) - name = p.tags.desc.get("ASCII", p.tags.desc.get("Unicode", p.tags.desc.get("Macintosh", p.tags.desc.get("en", {}).get("US", "ICC Profile")))).encode("latin1", "replace")[:79] - except ImportError: - name = b"ICC Profile" - data = name or b'ICC Profile' + b"\0\0" + zlib.compress(im.info["icc_profile"]) + name = b"ICC Profile" + data = name + b"\0\0" + zlib.compress(im.info["icc_profile"]) chunk(fp, b"iCCP", data) ImageFile._save(im, _idat(fp, chunk), [("zip", (0,0)+im.size, 0, rawmode)]) diff --git a/Tests/images/trollface.png b/Tests/images/trollface.png new file mode 100644 index 0000000000000000000000000000000000000000..f90ebe545a482e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i=*k~DqlEwmeH!MiKp(!Qp@$tS1BgAV?z25I)~F}{#Db5vHFEN^ z@1^c%-~akuX!L7k@Sh&xN*+?B4Z?5r)u@**lHSwPJ%i*=)e*a>qlV4=MtpDVh%s}H zIK6X)9qlT;6}hlICo4lR`$l*TLQyF%M4|FaTs_HKHrXAG6`LUH?(!FLpXKZgyfOg9 z;W(1^4*aEkuVllGWYAcy8A32coW}_VF!yGyas_xTwF&7 zLPeyo7hR_2j;(#gE92p|0`Hwu0tbZNv^$0%%gbvJHW#jHyyzxt#He%POmlm4&G?}a z!I3TdxcZ&@7}1lC=hEM7jsq|JEqv=h#sV-h0}}xdtXH(lKIB z0(|w)%XfwG`m53AOwYU_anm|85EUgAS#OW;{I($WYzUOM*+KZW|N69QveR-3bY&pSw)y`FaXOYq;#&?r z&>+VjE*gT@8=;Y$JFZ#OtAdtmRu!$Px#p}6ok!iaDJAx z_XZHps{=r+uR$OapM2dp7<`rTC-Uj9R`?oeeoD1#2!!_<1hV=C*PX-RZw;EZO4-c) zOylEk=Kz5D8U!-&#n+uf@u*at7yx2<4FZ|?hU;e-j+4#rC4UWqXXBgipJ_1e8URZE x8U!-&TGI^NH5_+0ehl_C2r(nC^S8{v{{vUS>+lcoXwCot002ovPDHLkV1kk@z;6Hm literal 0 HcmV?d00001 diff --git a/Tests/test_file_png.py b/Tests/test_file_png.py index 99b00f718..73a3fff15 100644 --- a/Tests/test_file_png.py +++ b/Tests/test_file_png.py @@ -252,8 +252,25 @@ def test_trns_rgb(): assert_equal(im.info["transparency"], (0, 1, 2)) def test_save_icc_profile_none(): + # check saving files with an ICC profile set to None (omit profile) in_file = "Tests/images/icc_profile_none.png" im = Image.open(in_file) + assert im.info['icc_profile'] is None file = tempfile("temp.png") assert_no_exception(lambda: im.save(file)) + im = Image.open(file) + assert 'icc_profile' not in im.info + +def test_save_icc_profile_exists(): + # check icc profile is kept during save() + in_file = "Tests/images/trollface.png" + im = Image.open(in_file) + orig_profile = im.info['icc_profile'] + assert len(orig_profile) == 6636 + + file = tempfile("temp.png") + assert_no_exception(lambda: im.save(file)) + + im = Image.open(file) + assert im.info['icc_profile'] == orig_profile From 0492409def4f309a33d580f01922e3e92bbaeeb9 Mon Sep 17 00:00:00 2001 From: wiredfool Date: Mon, 20 Jan 2014 13:34:48 -0800 Subject: [PATCH 3/4] don't use bare asserts, don't mask file builtin with local --- Tests/test_file_png.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Tests/test_file_png.py b/Tests/test_file_png.py index 73a3fff15..07e7e5385 100644 --- a/Tests/test_file_png.py +++ b/Tests/test_file_png.py @@ -255,22 +255,22 @@ def test_save_icc_profile_none(): # check saving files with an ICC profile set to None (omit profile) in_file = "Tests/images/icc_profile_none.png" im = Image.open(in_file) - assert im.info['icc_profile'] is None + assert_equal(im.info['icc_profile'], None) - file = tempfile("temp.png") - assert_no_exception(lambda: im.save(file)) - im = Image.open(file) - assert 'icc_profile' not in im.info + f = tempfile("temp.png") + assert_no_exception(lambda: im.save(f)) + im = Image.open(f) + assert_false('icc_profile' in im.info) def test_save_icc_profile_exists(): # check icc profile is kept during save() in_file = "Tests/images/trollface.png" im = Image.open(in_file) orig_profile = im.info['icc_profile'] - assert len(orig_profile) == 6636 + assert_equal(len(orig_profile), 6636) - file = tempfile("temp.png") - assert_no_exception(lambda: im.save(file)) + f = tempfile("temp.png") + assert_no_exception(lambda: im.save(f)) - im = Image.open(file) - assert im.info['icc_profile'] == orig_profile + im = Image.open(f) + assert_equal(im.info['icc_profile'], orig_profile) From 598bd0265097aac1504b61c4ec405bd39ccae00b Mon Sep 17 00:00:00 2001 From: wiredfool Date: Tue, 21 Jan 2014 20:50:54 -0800 Subject: [PATCH 4/4] Tightened up the tests --- Tests/images/trollface.png | Bin 13871 -> 0 bytes Tests/test_file_png.py | 23 ++++++++++------------- 2 files changed, 10 insertions(+), 13 deletions(-) delete mode 100644 Tests/images/trollface.png diff --git a/Tests/images/trollface.png b/Tests/images/trollface.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O-V0uO8W<%lCQf(pqXJL_*JSUxYc+}&xe#-e ztEc&Is8s|{$vrWi=*k~DqlEwmeH!MiKp(!Qp@$tS1BgAV?z25I)~F}{#Db5vHFEN^ z@1^c%-~akuX!L7k@Sh&xN*+?B4Z?5r)u@**lHSwPJ%i*=)e*a>qlV4=MtpDVh%s}H zIK6X)9qlT;6}hlICo4lR`$l*TLQyF%M4|FaTs_HKHrXAG6`LUH?(!FLpXKZgyfOg9 z;W(1^4*aEkuVllGWYAcy8A32coW}_VF!yGyas_xTwF&7 zLPeyo7hR_2j;(#gE92p|0`Hwu0tbZNv^$0%%gbvJHW#jHyyzxt#He%POmlm4&G?}a z!I3TdxcZ&@7}1lC=hEM7jsq|JEqv=h#sV-h0}}xdtXH(lKIB z0(|w)%XfwG`m53AOwYU_anm|85EUgAS#OW;{I($WYzUOM*+KZW|N69QveR-3bY&pSw)y`FaXOYq;#&?r z&>+VjE*gT@8=;Y$JFZ#OtAdtmRu!$Px#p}6ok!iaDJAx z_XZHps{=r+uR$OapM2dp7<`rTC-Uj9R`?oeeoD1#2!!_<1hV=C*PX-RZw;EZO4-c) zOylEk=Kz5D8U!-&#n+uf@u*at7yx2<4FZ|?hU;e-j+4#rC4UWqXXBgipJ_1e8URZE x8U!-&TGI^NH5_+0ehl_C2r(nC^S8{v{{vUS>+lcoXwCot002ovPDHLkV1kk@z;6Hm diff --git a/Tests/test_file_png.py b/Tests/test_file_png.py index 07e7e5385..e8d2a1208 100644 --- a/Tests/test_file_png.py +++ b/Tests/test_file_png.py @@ -257,20 +257,17 @@ def test_save_icc_profile_none(): im = Image.open(in_file) assert_equal(im.info['icc_profile'], None) - f = tempfile("temp.png") - assert_no_exception(lambda: im.save(f)) - im = Image.open(f) + im = roundtrip(im) assert_false('icc_profile' in im.info) -def test_save_icc_profile_exists(): - # check icc profile is kept during save() - in_file = "Tests/images/trollface.png" - im = Image.open(in_file) - orig_profile = im.info['icc_profile'] - assert_equal(len(orig_profile), 6636) +def test_roundtrip_icc_profile(): + # check that we can roundtrip the icc profile + im = lena('RGB') - f = tempfile("temp.png") - assert_no_exception(lambda: im.save(f)) + jpeg_image = Image.open('Tests/images/flower2.jpg') + expected_icc = jpeg_image.info['icc_profile'] + + im.info['icc_profile'] = expected_icc + im = roundtrip(im) + assert_equal(im.info['icc_profile'], expected_icc) - im = Image.open(f) - assert_equal(im.info['icc_profile'], orig_profile)