diff --git a/src/PIL/PyAccess.py b/src/PIL/PyAccess.py index cce2de2b8..395dbcd3b 100644 --- a/src/PIL/PyAccess.py +++ b/src/PIL/PyAccess.py @@ -88,8 +88,12 @@ class PyAccess(object): :returns: a pixel value for single band images, a tuple of pixel values for multiband images. """ - - (x, y) = self.check_xy(xy) + (x, y) = xy + if (x < 0): + x = self.xsize + x + if (y < 0): + y = self.ysize + y + (x, y) = self.check_xy((x, y)) return self.get_pixel(x, y) putpixel = __setitem__ diff --git a/src/_imaging.c b/src/_imaging.c index e4b31f10b..ede531e03 100644 --- a/src/_imaging.c +++ b/src/_imaging.c @@ -471,7 +471,12 @@ getpixel(Imaging im, ImagingAccess access, int x, int y) INT32 i; FLOAT32 f; } pixel; - + if (x < 0){ + x = im->xsize + x; + } + if (y < 0){ + y = im->ysize + y; + } if (x < 0 || x >= im->xsize || y < 0 || y >= im->ysize) { PyErr_SetString(PyExc_IndexError, outside_image); return NULL;