diff --git a/PIL/Image.py b/PIL/Image.py index 9c459dfb1..37428ec30 100644 --- a/PIL/Image.py +++ b/PIL/Image.py @@ -1288,11 +1288,11 @@ class Image: images (in the latter case, the alpha band is used as mask). Where the mask is 255, the given image is copied as is. Where the mask is 0, the current value is preserved. Intermediate - values can be used for transparency effects. + values will mix the two images together, including their alpha + channels if they have them. - Note that if you paste an "RGBA" image, the alpha band is - ignored. You can work around this by using the same image as - both source image and mask. + See :py:meth:`~PIL.Image.Image.alpha_composite` if you want to + combine images with respect to their alpha channels. :param im: Source image or pixel value (integer or tuple). :param box: An optional 4-tuple giving the region to paste into. diff --git a/PIL/JpegImagePlugin.py b/PIL/JpegImagePlugin.py index 01a173b5b..e15042504 100644 --- a/PIL/JpegImagePlugin.py +++ b/PIL/JpegImagePlugin.py @@ -704,7 +704,7 @@ def _save_cjpeg(im, fp, filename): tempfile = im._dump() subprocess.check_call(["cjpeg", "-outfile", filename, tempfile]) try: - os.unlink(file) + os.unlink(tempfile) except: pass diff --git a/Tests/test_file_icns.py b/Tests/test_file_icns.py index 2edf9dd20..67eb1335f 100644 --- a/Tests/test_file_icns.py +++ b/Tests/test_file_icns.py @@ -5,8 +5,8 @@ from PIL import Image import sys # sample icon file -test_file = "Tests/images/pillow.icns" -data = open(test_file, "rb").read() +TEST_FILE = "Tests/images/pillow.icns" +data = open(TEST_FILE, "rb").read() enable_jpeg2k = hasattr(Image.core, 'jp2klib_version') @@ -16,7 +16,7 @@ class TestFileIcns(PillowTestCase): def test_sanity(self): # Loading this icon by default should result in the largest size # (512x512@2x) being loaded - im = Image.open(test_file) + im = Image.open(TEST_FILE) im.load() self.assertEqual(im.mode, "RGBA") self.assertEqual(im.size, (1024, 1024)) @@ -25,12 +25,12 @@ class TestFileIcns(PillowTestCase): @unittest.skipIf(sys.platform != 'darwin', "requires MacOS") def test_save(self): - im = Image.open(file) + im = Image.open(TEST_FILE) - test_file = self.tempfile("temp.icns") - im.save(test_file) + temp_file = self.tempfile("temp.icns") + im.save(temp_file) - reread = Image.open(test_file) + reread = Image.open(temp_file) self.assertEqual(reread.mode, "RGBA") self.assertEqual(reread.size, (1024, 1024)) @@ -39,11 +39,11 @@ class TestFileIcns(PillowTestCase): def test_sizes(self): # Check that we can load all of the sizes, and that the final pixel # dimensions are as expected - im = Image.open(test_file) + im = Image.open(TEST_FILE) for w, h, r in im.info['sizes']: wr = w * r hr = h * r - im2 = Image.open(test_file) + im2 = Image.open(TEST_FILE) im2.size = (w, h, r) im2.load() self.assertEqual(im2.mode, 'RGBA')