mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 17:36:18 +03:00
Merge branch 'master' of github.com:python-pillow/Pillow [ci skip]
This commit is contained in:
commit
55ec522727
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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')
|
||||
|
|
Loading…
Reference in New Issue
Block a user