Merge branch 'master' of github.com:python-pillow/Pillow [ci skip]

This commit is contained in:
Alex Clark 2015-05-08 07:29:03 -04:00
commit 55ec522727
3 changed files with 14 additions and 14 deletions

View File

@ -1288,11 +1288,11 @@ class Image:
images (in the latter case, the alpha band is used as mask). 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 Where the mask is 255, the given image is copied as is. Where
the mask is 0, the current value is preserved. Intermediate 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 See :py:meth:`~PIL.Image.Image.alpha_composite` if you want to
ignored. You can work around this by using the same image as combine images with respect to their alpha channels.
both source image and mask.
:param im: Source image or pixel value (integer or tuple). :param im: Source image or pixel value (integer or tuple).
:param box: An optional 4-tuple giving the region to paste into. :param box: An optional 4-tuple giving the region to paste into.

View File

@ -704,7 +704,7 @@ def _save_cjpeg(im, fp, filename):
tempfile = im._dump() tempfile = im._dump()
subprocess.check_call(["cjpeg", "-outfile", filename, tempfile]) subprocess.check_call(["cjpeg", "-outfile", filename, tempfile])
try: try:
os.unlink(file) os.unlink(tempfile)
except: except:
pass pass

View File

@ -5,8 +5,8 @@ from PIL import Image
import sys import sys
# sample icon file # sample icon file
test_file = "Tests/images/pillow.icns" TEST_FILE = "Tests/images/pillow.icns"
data = open(test_file, "rb").read() data = open(TEST_FILE, "rb").read()
enable_jpeg2k = hasattr(Image.core, 'jp2klib_version') enable_jpeg2k = hasattr(Image.core, 'jp2klib_version')
@ -16,7 +16,7 @@ class TestFileIcns(PillowTestCase):
def test_sanity(self): def test_sanity(self):
# Loading this icon by default should result in the largest size # Loading this icon by default should result in the largest size
# (512x512@2x) being loaded # (512x512@2x) being loaded
im = Image.open(test_file) im = Image.open(TEST_FILE)
im.load() im.load()
self.assertEqual(im.mode, "RGBA") self.assertEqual(im.mode, "RGBA")
self.assertEqual(im.size, (1024, 1024)) self.assertEqual(im.size, (1024, 1024))
@ -25,12 +25,12 @@ class TestFileIcns(PillowTestCase):
@unittest.skipIf(sys.platform != 'darwin', @unittest.skipIf(sys.platform != 'darwin',
"requires MacOS") "requires MacOS")
def test_save(self): def test_save(self):
im = Image.open(file) im = Image.open(TEST_FILE)
test_file = self.tempfile("temp.icns") temp_file = self.tempfile("temp.icns")
im.save(test_file) im.save(temp_file)
reread = Image.open(test_file) reread = Image.open(temp_file)
self.assertEqual(reread.mode, "RGBA") self.assertEqual(reread.mode, "RGBA")
self.assertEqual(reread.size, (1024, 1024)) self.assertEqual(reread.size, (1024, 1024))
@ -39,11 +39,11 @@ class TestFileIcns(PillowTestCase):
def test_sizes(self): def test_sizes(self):
# Check that we can load all of the sizes, and that the final pixel # Check that we can load all of the sizes, and that the final pixel
# dimensions are as expected # dimensions are as expected
im = Image.open(test_file) im = Image.open(TEST_FILE)
for w, h, r in im.info['sizes']: for w, h, r in im.info['sizes']:
wr = w * r wr = w * r
hr = h * r hr = h * r
im2 = Image.open(test_file) im2 = Image.open(TEST_FILE)
im2.size = (w, h, r) im2.size = (w, h, r)
im2.load() im2.load()
self.assertEqual(im2.mode, 'RGBA') self.assertEqual(im2.mode, 'RGBA')