Merge pull request #38 from d-schmidt/master

Fixed some bugs related to the features added yesterday
This commit is contained in:
Alex Clark ☺ 2013-01-16 07:14:26 -08:00
commit 8fc5fbc6c1
5 changed files with 8 additions and 9 deletions

View File

@ -324,7 +324,7 @@ def _save_netpbm(im, fp, filename):
# -------------------------------------------------------------------- # --------------------------------------------------------------------
# GIF utilities # GIF utilities
def getheader(im, palette, info=None): def getheader(im, palette=None, info=None):
"""Return a list of strings representing a GIF header""" """Return a list of strings representing a GIF header"""
optimize = info and info.get("optimize", 0) optimize = info and info.get("optimize", 0)
@ -352,7 +352,7 @@ def getheader(im, palette, info=None):
# global palette # global palette
if im.mode == "P": if im.mode == "P":
# colour palette # colour palette
if palette is not None and Image.isBytesType(palette): if palette is not None and isinstance(palette, bytes):
paletteBytes = palette paletteBytes = palette
else: else:
paletteBytes =im.im.getpalette("RGB")[:maxcolor*3] paletteBytes =im.im.getpalette("RGB")[:maxcolor*3]

View File

@ -226,9 +226,8 @@ class ImageFile(Image.Image):
self.fp = None # might be shared self.fp = None # might be shared
if not LOAD_TRUNCATED_IMAGES and not self.map and e < 0: if (t == 0 or not LOAD_TRUNCATED_IMAGES) and not self.map and e < 0:
# Note: If loading a truncated image results in an all black Image, # still raised if decoder fails to return anything
# the decoder wasn't able to decode anything.
raise_ioerror(e) raise_ioerror(e)
# post processing # post processing

View File

@ -465,7 +465,7 @@ def _save(im, fp, filename):
dpi[0], dpi[1], dpi[0], dpi[1],
subsampling, subsampling,
extra, extra,
info.get("exif", "") info.get("exif", b"")
) )
ImageFile._save(im, fp, [("jpeg", (0,0)+im.size, 0, rawmode)]) ImageFile._save(im, fp, [("jpeg", (0,0)+im.size, 0, rawmode)])

View File

@ -525,7 +525,7 @@ PyImaging_JpegEncoderNew(PyObject* self, PyObject* args)
char* rawExif = NULL; char* rawExif = NULL;
int rawExifLen = 0; int rawExifLen = 0;
if (!PyArg_ParseTuple(args, "ss|iiiiiiii"PY_ARG_BYTES_LENGTH, if (!PyArg_ParseTuple(args, "ss|iiiiiiii"PY_ARG_BYTES_LENGTH""PY_ARG_BYTES_LENGTH,
&mode, &rawmode, &quality, &mode, &rawmode, &quality,
&progressive, &smooth, &optimize, &streamtype, &progressive, &smooth, &optimize, &streamtype,
&xdpi, &ydpi, &subsampling, &extra, &extra_size, &xdpi, &ydpi, &subsampling, &extra, &extra_size,

4
py3.h
View File

@ -11,7 +11,7 @@
*/ */
#if PY_VERSION_HEX >= 0x03000000 #if PY_VERSION_HEX >= 0x03000000
#define PY_ARG_BYTES_LENGTH "y#y#" #define PY_ARG_BYTES_LENGTH "y#"
/* Map PyInt -> PyLong */ /* Map PyInt -> PyLong */
#define PyInt_AsLong PyLong_AsLong #define PyInt_AsLong PyLong_AsLong
@ -20,7 +20,7 @@
#define PyInt_AS_LONG PyLong_AS_LONG #define PyInt_AS_LONG PyLong_AS_LONG
#else /* PY_VERSION_HEX < 0x03000000 */ #else /* PY_VERSION_HEX < 0x03000000 */
#define PY_ARG_BYTES_LENGTH "s#s#" #define PY_ARG_BYTES_LENGTH "s#"
#if !defined(KEEP_PY_UNICODE) #if !defined(KEEP_PY_UNICODE)
/* Map PyUnicode -> PyString */ /* Map PyUnicode -> PyString */