diff --git a/CHANGES.rst b/CHANGES.rst index cc92eba8d..cd00ce285 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,13 +4,25 @@ Changelog (Pillow) 2.6.0 (unreleased) ------------------ -- Jpeg2k Decode/Encode Memory Leak Fix #898 +- On Windows, do not execute convert.exe without specifying path #912 + [cgohlke] + +- Fix msvc build error #911 + [cgohlke] + +- Fix for handling P + transparency -> RGBA conversions #904 + [wiredfool] + +- Retain alpha in ImageEnhance operations #909 + [wiredfool] + +- Jpeg2k Decode/encode memory leak fix #898 [joshware, wiredfool] - EpsFilePlugin Speed improvements #886 [wiredfool, karstenw] -- Don't resize if already the right size. +- Don't resize if already the right size #892 [radarhere] - Fix for reading multipage TIFFs #885 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a31c9ee09..30c375a17 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -7,7 +7,7 @@ Send a pull request. We'll generally want documentation and [tests](Tests/README - Fork the repo - Make a branch - Add your changes + Tests -- Run the test suite. Try to run on both Python 2.x and 3.x, or you'll get tripped up. You can enable [Travis CI on your repo](https://travis-ci.org/profile/) to catch test failures prior to the pull request. +- Run the test suite. Try to run on both Python 2.x and 3.x, or you'll get tripped up. You can enable [Travis CI on your repo](https://travis-ci.org/profile/) to catch test failures prior to the pull request, and [Coveralls](https://coveralls.io/repos/new) to see if the changed code is covered by tests. - Push to your fork, and make a pull request. A few guidelines: diff --git a/PIL/Image.py b/PIL/Image.py index 76f3ab0a5..34b49c802 100644 --- a/PIL/Image.py +++ b/PIL/Image.py @@ -531,7 +531,7 @@ class Image: """ Closes the file pointer, if possible. - This operation will destroy the image core and release it's memory. + This operation will destroy the image core and release its memory. The image data will be unusable afterward. This function is only required to close images that have not @@ -869,7 +869,17 @@ class Image: trns = trns_im.getpixel((0, 0)) elif self.mode == 'P' and mode == 'RGBA': + t = self.info['transparency'] delete_trns = True + + if isinstance(t, bytes): + self.im.putpalettealphas(t) + elif isinstance(t, int): + self.im.putpalettealpha(t,0) + else: + raise ValueError("Transparency for P mode should" + + " be bytes or int") + if mode == "P" and palette == ADAPTIVE: im = self.im.quantize(colors) diff --git a/PIL/ImageEnhance.py b/PIL/ImageEnhance.py index f802dc1d3..a196d5b09 100644 --- a/PIL/ImageEnhance.py +++ b/PIL/ImageEnhance.py @@ -47,8 +47,11 @@ class Color(_Enhance): """ def __init__(self, image): self.image = image - self.degenerate = image.convert("L").convert(image.mode) + self.intermediate_mode = 'L' + if 'A' in image.getbands(): + self.intermediate_mode = 'LA' + self.degenerate = image.convert(self.intermediate_mode).convert(image.mode) class Contrast(_Enhance): """Adjust image contrast. @@ -62,6 +65,9 @@ class Contrast(_Enhance): mean = int(ImageStat.Stat(image.convert("L")).mean[0] + 0.5) self.degenerate = Image.new("L", image.size, mean).convert(image.mode) + if 'A' in image.getbands(): + self.degenerate.putalpha(image.split()[-1]) + class Brightness(_Enhance): """Adjust image brightness. @@ -74,6 +80,9 @@ class Brightness(_Enhance): self.image = image self.degenerate = Image.new(image.mode, image.size, 0) + if 'A' in image.getbands(): + self.degenerate.putalpha(image.split()[-1]) + class Sharpness(_Enhance): """Adjust image sharpness. @@ -85,3 +94,6 @@ class Sharpness(_Enhance): def __init__(self, image): self.image = image self.degenerate = image.filter(ImageFilter.SMOOTH) + + if 'A' in image.getbands(): + self.degenerate.putalpha(image.split()[-1]) diff --git a/PIL/ImageGrab.py b/PIL/ImageGrab.py index ac925b683..ef0135334 100644 --- a/PIL/ImageGrab.py +++ b/PIL/ImageGrab.py @@ -17,6 +17,9 @@ from PIL import Image +import sys +if sys.platform != "win32": + raise ImportError("ImageGrab is Windows only") try: # built-in driver (1.1.3 and later) diff --git a/README.rst b/README.rst index d58666bc6..a5cb77785 100644 --- a/README.rst +++ b/README.rst @@ -19,7 +19,3 @@ Pillow is the "friendly" PIL fork by `Alex Clark and Contributors ifd){ - unsigned int ifdoffset = clientstate->ifd; + int rv; + unsigned int ifdoffset = clientstate->ifd; TRACE(("reading tiff ifd %d\n", ifdoffset)); - int rv = TIFFSetSubDirectory(tiff, ifdoffset); + rv = TIFFSetSubDirectory(tiff, ifdoffset); if (!rv){ TRACE(("error in TIFFSetSubDirectory")); return -1;