From 5f77c39090701dd45cb7f4d7e968f3abc39cec28 Mon Sep 17 00:00:00 2001 From: Alastair Houghton Date: Mon, 24 Mar 2014 17:24:49 +0000 Subject: [PATCH] Added JPEG 2000 support for .icns files. --- PIL/IcnsImagePlugin.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/PIL/IcnsImagePlugin.py b/PIL/IcnsImagePlugin.py index bfd802a4e..0dea0994e 100644 --- a/PIL/IcnsImagePlugin.py +++ b/PIL/IcnsImagePlugin.py @@ -15,7 +15,7 @@ # See the README file for information on usage and redistribution. # -from PIL import Image, ImageFile, PngImagePlugin, _binary +from PIL import Image, ImageFile, PngImagePlugin, Jpeg2KImagePlugin, _binary import struct i8 = _binary.i8 @@ -102,7 +102,11 @@ def read_png_or_jpeg2000(fobj, start_length, size): or sig[:4] == b'\x0d\x0a\x87\x0a' \ or sig == b'\x00\x00\x00\x0cjP \x0d\x0a\x87\x0a': # j2k, jpc or j2c - raise ValueError('Cannot decode JPEG 2000 icons yet (sorry)') + fobj.seek(start) + im = Jpeg2KImagePlugin.Jpeg2KImageFile(fobj) + if im.mode != 'RGBA': + im = im.convert('RGBA') + return {"RGBA": im} class IcnsFile: