From cc439099c1e8c81a929ea446caa6791d7d9b6bd6 Mon Sep 17 00:00:00 2001 From: Sandro Mani Date: Wed, 6 Feb 2013 00:49:26 +0100 Subject: [PATCH 1/2] Fix saving images with added transparency See http://mail.python.org/pipermail/image-sig/1999-February/000648.html This patch was carried by fedora for python-imaging --- PIL/GifImagePlugin.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/PIL/GifImagePlugin.py b/PIL/GifImagePlugin.py index 443d4db12..203689320 100644 --- a/PIL/GifImagePlugin.py +++ b/PIL/GifImagePlugin.py @@ -364,6 +364,11 @@ def getheader(im, palette=None, info=None): for i in range(maxcolor): s.append(o8(i) * 3) + if im.info.has_key('transparency'): + transparentIndex = im.info['transparency'] + s.append('!' + o8(0xf9) + o8(4) + o8(1) + o8(0) + o8(0) + + o8(transparentIndex) + o8(0)) + return s def getdata(im, offset = (0, 0), **params): From 8c7c3736767e2e86bec46e239438dea0a93ea4a3 Mon Sep 17 00:00:00 2001 From: Sandro Mani Date: Wed, 6 Feb 2013 00:51:25 +0100 Subject: [PATCH 2/2] Fix buffer overflow This patch was carried by fedora for python-imaging See https://bugzilla.redhat.com/show_bug.cgi?id=703212 --- libImaging/Imaging.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libImaging/Imaging.h b/libImaging/Imaging.h index e2033022a..76861a0df 100644 --- a/libImaging/Imaging.h +++ b/libImaging/Imaging.h @@ -75,7 +75,7 @@ typedef struct ImagingPaletteInstance* ImagingPalette; struct ImagingMemoryInstance { /* Format */ - char mode[4+1]; /* Band names ("1", "L", "P", "RGB", "RGBA", "CMYK") */ + char mode[6+1]; /* Band names ("1", "L", "P", "RGB", "RGBA", "CMYK", "YCbCr", "BGR;xy") */ int type; /* Data type (IMAGING_TYPE_*) */ int depth; /* Depth (ignored in this version) */ int bands; /* Number of bands (1, 2, 3, or 4) */