mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 18:06:18 +03:00
Replace some lena with hopper
This commit is contained in:
parent
bd3e54938f
commit
a2e729f487
Binary file not shown.
Before Width: | Height: | Size: 4.7 KiB |
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 1.9 KiB |
Binary file not shown.
Before Width: | Height: | Size: 22 KiB |
|
@ -1,4 +1,4 @@
|
|||
from helper import unittest, PillowTestCase, lena, py3
|
||||
from helper import unittest, PillowTestCase, hopper, py3
|
||||
from helper import djpeg_available, cjpeg_available
|
||||
|
||||
import random
|
||||
|
@ -10,7 +10,7 @@ from PIL import JpegImagePlugin
|
|||
|
||||
codecs = dir(Image.core)
|
||||
|
||||
test_file = "Tests/images/lena.jpg"
|
||||
TEST_FILE = "Tests/images/hopper.jpg"
|
||||
|
||||
|
||||
class TestFileJpeg(PillowTestCase):
|
||||
|
@ -33,7 +33,7 @@ class TestFileJpeg(PillowTestCase):
|
|||
# internal version number
|
||||
self.assertRegexpMatches(Image.core.jpeglib_version, "\d+\.\d+$")
|
||||
|
||||
im = Image.open(test_file)
|
||||
im = Image.open(TEST_FILE)
|
||||
im.load()
|
||||
self.assertEqual(im.mode, "RGB")
|
||||
self.assertEqual(im.size, (128, 128))
|
||||
|
@ -41,7 +41,7 @@ class TestFileJpeg(PillowTestCase):
|
|||
|
||||
def test_app(self):
|
||||
# Test APP/COM reader (@PIL135)
|
||||
im = Image.open(test_file)
|
||||
im = Image.open(TEST_FILE)
|
||||
self.assertEqual(
|
||||
im.applist[0],
|
||||
("APP0", b"JFIF\x00\x01\x01\x00\x00\x01\x00\x01\x00\x00"))
|
||||
|
@ -76,7 +76,7 @@ class TestFileJpeg(PillowTestCase):
|
|||
|
||||
def test_dpi(self):
|
||||
def test(xdpi, ydpi=None):
|
||||
im = Image.open(test_file)
|
||||
im = Image.open(TEST_FILE)
|
||||
im = self.roundtrip(im, dpi=(xdpi, ydpi or xdpi))
|
||||
return im.info.get("dpi")
|
||||
self.assertEqual(test(72), (72, 72))
|
||||
|
@ -95,8 +95,8 @@ class TestFileJpeg(PillowTestCase):
|
|||
im2 = Image.open(f)
|
||||
self.assertEqual(im2.info.get("icc_profile"), icc_profile)
|
||||
# Roundtrip via memory buffer.
|
||||
im1 = self.roundtrip(lena())
|
||||
im2 = self.roundtrip(lena(), icc_profile=icc_profile)
|
||||
im1 = self.roundtrip(hopper())
|
||||
im2 = self.roundtrip(hopper(), icc_profile=icc_profile)
|
||||
self.assert_image_equal(im1, im2)
|
||||
self.assertFalse(im1.info.get("icc_profile"))
|
||||
self.assertTrue(im2.info.get("icc_profile"))
|
||||
|
@ -109,7 +109,7 @@ class TestFileJpeg(PillowTestCase):
|
|||
# order issues.
|
||||
icc_profile = (b"Test"*int(n/4+1))[:n]
|
||||
assert len(icc_profile) == n # sanity
|
||||
im1 = self.roundtrip(lena(), icc_profile=icc_profile)
|
||||
im1 = self.roundtrip(hopper(), icc_profile=icc_profile)
|
||||
self.assertEqual(im1.info.get("icc_profile"), icc_profile or None)
|
||||
test(0)
|
||||
test(1)
|
||||
|
@ -123,8 +123,8 @@ class TestFileJpeg(PillowTestCase):
|
|||
test(ImageFile.MAXBLOCK*4+3) # large block
|
||||
|
||||
def test_optimize(self):
|
||||
im1 = self.roundtrip(lena())
|
||||
im2 = self.roundtrip(lena(), optimize=1)
|
||||
im1 = self.roundtrip(hopper())
|
||||
im2 = self.roundtrip(hopper(), optimize=1)
|
||||
self.assert_image_equal(im1, im2)
|
||||
self.assertGreaterEqual(im1.bytes, im2.bytes)
|
||||
|
||||
|
@ -136,8 +136,8 @@ class TestFileJpeg(PillowTestCase):
|
|||
im.save(f, format="JPEG", optimize=True)
|
||||
|
||||
def test_progressive(self):
|
||||
im1 = self.roundtrip(lena())
|
||||
im2 = self.roundtrip(lena(), progressive=True)
|
||||
im1 = self.roundtrip(hopper())
|
||||
im2 = self.roundtrip(hopper(), progressive=True)
|
||||
self.assert_image_equal(im1, im2)
|
||||
self.assertGreaterEqual(im1.bytes, im2.bytes)
|
||||
|
||||
|
@ -161,13 +161,13 @@ class TestFileJpeg(PillowTestCase):
|
|||
def test_large_exif(self):
|
||||
# https://github.com/python-pillow/Pillow/issues/148
|
||||
f = self.tempfile('temp.jpg')
|
||||
im = lena()
|
||||
im = hopper()
|
||||
im.save(f, 'JPEG', quality=90, exif=b"1"*65532)
|
||||
|
||||
def test_progressive_compat(self):
|
||||
im1 = self.roundtrip(lena())
|
||||
im2 = self.roundtrip(lena(), progressive=1)
|
||||
im3 = self.roundtrip(lena(), progression=1) # compatibility
|
||||
im1 = self.roundtrip(hopper())
|
||||
im2 = self.roundtrip(hopper(), progressive=1)
|
||||
im3 = self.roundtrip(hopper(), progression=1) # compatibility
|
||||
self.assert_image_equal(im1, im2)
|
||||
self.assert_image_equal(im1, im3)
|
||||
self.assertFalse(im1.info.get("progressive"))
|
||||
|
@ -178,14 +178,14 @@ class TestFileJpeg(PillowTestCase):
|
|||
self.assertTrue(im3.info.get("progression"))
|
||||
|
||||
def test_quality(self):
|
||||
im1 = self.roundtrip(lena())
|
||||
im2 = self.roundtrip(lena(), quality=50)
|
||||
im1 = self.roundtrip(hopper())
|
||||
im2 = self.roundtrip(hopper(), quality=50)
|
||||
self.assert_image(im1, im2.mode, im2.size)
|
||||
self.assertGreaterEqual(im1.bytes, im2.bytes)
|
||||
|
||||
def test_smooth(self):
|
||||
im1 = self.roundtrip(lena())
|
||||
im2 = self.roundtrip(lena(), smooth=100)
|
||||
im1 = self.roundtrip(hopper())
|
||||
im2 = self.roundtrip(hopper(), smooth=100)
|
||||
self.assert_image(im1, im2.mode, im2.size)
|
||||
|
||||
def test_subsampling(self):
|
||||
|
@ -193,26 +193,26 @@ class TestFileJpeg(PillowTestCase):
|
|||
layer = im.layer
|
||||
return layer[0][1:3] + layer[1][1:3] + layer[2][1:3]
|
||||
# experimental API
|
||||
im = self.roundtrip(lena(), subsampling=-1) # default
|
||||
im = self.roundtrip(hopper(), subsampling=-1) # default
|
||||
self.assertEqual(getsampling(im), (2, 2, 1, 1, 1, 1))
|
||||
im = self.roundtrip(lena(), subsampling=0) # 4:4:4
|
||||
im = self.roundtrip(hopper(), subsampling=0) # 4:4:4
|
||||
self.assertEqual(getsampling(im), (1, 1, 1, 1, 1, 1))
|
||||
im = self.roundtrip(lena(), subsampling=1) # 4:2:2
|
||||
im = self.roundtrip(hopper(), subsampling=1) # 4:2:2
|
||||
self.assertEqual(getsampling(im), (2, 1, 1, 1, 1, 1))
|
||||
im = self.roundtrip(lena(), subsampling=2) # 4:1:1
|
||||
im = self.roundtrip(hopper(), subsampling=2) # 4:1:1
|
||||
self.assertEqual(getsampling(im), (2, 2, 1, 1, 1, 1))
|
||||
im = self.roundtrip(lena(), subsampling=3) # default (undefined)
|
||||
im = self.roundtrip(hopper(), subsampling=3) # default (undefined)
|
||||
self.assertEqual(getsampling(im), (2, 2, 1, 1, 1, 1))
|
||||
|
||||
im = self.roundtrip(lena(), subsampling="4:4:4")
|
||||
im = self.roundtrip(hopper(), subsampling="4:4:4")
|
||||
self.assertEqual(getsampling(im), (1, 1, 1, 1, 1, 1))
|
||||
im = self.roundtrip(lena(), subsampling="4:2:2")
|
||||
im = self.roundtrip(hopper(), subsampling="4:2:2")
|
||||
self.assertEqual(getsampling(im), (2, 1, 1, 1, 1, 1))
|
||||
im = self.roundtrip(lena(), subsampling="4:1:1")
|
||||
im = self.roundtrip(hopper(), subsampling="4:1:1")
|
||||
self.assertEqual(getsampling(im), (2, 2, 1, 1, 1, 1))
|
||||
|
||||
self.assertRaises(
|
||||
TypeError, lambda: self.roundtrip(lena(), subsampling="1:1:1"))
|
||||
TypeError, lambda: self.roundtrip(hopper(), subsampling="1:1:1"))
|
||||
|
||||
def test_exif(self):
|
||||
im = Image.open("Tests/images/pil_sample_rgb.jpg")
|
||||
|
@ -225,11 +225,11 @@ class TestFileJpeg(PillowTestCase):
|
|||
|
||||
def test_quality_keep(self):
|
||||
# RGB
|
||||
im = Image.open("Tests/images/lena.jpg")
|
||||
im = Image.open("Tests/images/hopper.jpg")
|
||||
f = self.tempfile('temp.jpg')
|
||||
im.save(f, quality='keep')
|
||||
# Grayscale
|
||||
im = Image.open("Tests/images/lena_gray.jpg")
|
||||
im = Image.open("Tests/images/hopper_gray.jpg")
|
||||
f = self.tempfile('temp.jpg')
|
||||
im.save(f, quality='keep')
|
||||
# CMYK
|
||||
|
@ -243,7 +243,7 @@ class TestFileJpeg(PillowTestCase):
|
|||
Image.open(filename)
|
||||
|
||||
def test_qtables(self):
|
||||
im = Image.open("Tests/images/lena.jpg")
|
||||
im = Image.open("Tests/images/hopper.jpg")
|
||||
qtables = im.quantization
|
||||
reloaded = self.roundtrip(im, qtables=qtables, subsampling=0)
|
||||
self.assertEqual(im.quantization, reloaded.quantization)
|
||||
|
@ -296,13 +296,13 @@ class TestFileJpeg(PillowTestCase):
|
|||
|
||||
@unittest.skipUnless(djpeg_available(), "djpeg not available")
|
||||
def test_load_djpeg(self):
|
||||
img = Image.open(test_file)
|
||||
img = Image.open(TEST_FILE)
|
||||
img.load_djpeg()
|
||||
self.assert_image_similar(img, Image.open(test_file), 0)
|
||||
self.assert_image_similar(img, Image.open(TEST_FILE), 0)
|
||||
|
||||
@unittest.skipUnless(cjpeg_available(), "cjpeg not available")
|
||||
def test_save_cjpeg(self):
|
||||
img = Image.open(test_file)
|
||||
img = Image.open(TEST_FILE)
|
||||
|
||||
tempfile = self.tempfile("temp.jpg")
|
||||
JpegImagePlugin._save_cjpeg(img, 0, tempfile)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from helper import unittest, PillowTestCase, lena
|
||||
from helper import unittest, PillowTestCase, hopper, lena
|
||||
|
||||
from PIL import Image
|
||||
|
||||
|
@ -38,36 +38,36 @@ class TestImageCms(PillowTestCase):
|
|||
# internal version number
|
||||
self.assertRegexpMatches(ImageCms.core.littlecms_version, "\d+\.\d+$")
|
||||
|
||||
i = ImageCms.profileToProfile(lena(), SRGB, SRGB)
|
||||
i = ImageCms.profileToProfile(hopper(), SRGB, SRGB)
|
||||
self.assert_image(i, "RGB", (128, 128))
|
||||
|
||||
i = lena()
|
||||
i = hopper()
|
||||
ImageCms.profileToProfile(i, SRGB, SRGB, inPlace=True)
|
||||
self.assert_image(i, "RGB", (128, 128))
|
||||
|
||||
t = ImageCms.buildTransform(SRGB, SRGB, "RGB", "RGB")
|
||||
i = ImageCms.applyTransform(lena(), t)
|
||||
i = ImageCms.applyTransform(hopper(), t)
|
||||
self.assert_image(i, "RGB", (128, 128))
|
||||
|
||||
i = lena()
|
||||
i = hopper()
|
||||
t = ImageCms.buildTransform(SRGB, SRGB, "RGB", "RGB")
|
||||
ImageCms.applyTransform(lena(), t, inPlace=True)
|
||||
ImageCms.applyTransform(hopper(), t, inPlace=True)
|
||||
self.assert_image(i, "RGB", (128, 128))
|
||||
|
||||
p = ImageCms.createProfile("sRGB")
|
||||
o = ImageCms.getOpenProfile(SRGB)
|
||||
t = ImageCms.buildTransformFromOpenProfiles(p, o, "RGB", "RGB")
|
||||
i = ImageCms.applyTransform(lena(), t)
|
||||
i = ImageCms.applyTransform(hopper(), t)
|
||||
self.assert_image(i, "RGB", (128, 128))
|
||||
|
||||
t = ImageCms.buildProofTransform(SRGB, SRGB, SRGB, "RGB", "RGB")
|
||||
self.assertEqual(t.inputMode, "RGB")
|
||||
self.assertEqual(t.outputMode, "RGB")
|
||||
i = ImageCms.applyTransform(lena(), t)
|
||||
i = ImageCms.applyTransform(hopper(), t)
|
||||
self.assert_image(i, "RGB", (128, 128))
|
||||
|
||||
# test PointTransform convenience API
|
||||
lena().point(t)
|
||||
hopper().point(t)
|
||||
|
||||
def test_name(self):
|
||||
# get profile information for file
|
||||
|
@ -132,7 +132,7 @@ class TestImageCms(PillowTestCase):
|
|||
# the procedural pyCMS API uses PyCMSError for all sorts of errors
|
||||
self.assertRaises(
|
||||
ImageCms.PyCMSError,
|
||||
lambda: ImageCms.profileToProfile(lena(), "foo", "bar"))
|
||||
lambda: ImageCms.profileToProfile(hopper(), "foo", "bar"))
|
||||
self.assertRaises(
|
||||
ImageCms.PyCMSError,
|
||||
lambda: ImageCms.buildTransform("foo", "bar", "RGB", "RGB"))
|
||||
|
@ -204,7 +204,6 @@ class TestImageCms(PillowTestCase):
|
|||
profile = ImageCmsProfile(BytesIO(img_srgb.info['icc_profile']))
|
||||
self.assertTrue('sRGB' in ImageCms.getProfileDescription(profile))
|
||||
|
||||
|
||||
def test_lab_roundtrip(self):
|
||||
# check to see if we're at least internally consistent.
|
||||
pLab = ImageCms.createProfile("LAB")
|
||||
|
@ -212,15 +211,14 @@ class TestImageCms(PillowTestCase):
|
|||
|
||||
t2 = ImageCms.buildTransform(pLab, SRGB, "LAB", "RGB")
|
||||
|
||||
i = ImageCms.applyTransform(lena(), t)
|
||||
i = ImageCms.applyTransform(hopper(), t)
|
||||
|
||||
self.assertEqual(i.info['icc_profile'],
|
||||
ImageCmsProfile(pLab).tobytes())
|
||||
|
||||
out = ImageCms.applyTransform(i, t2)
|
||||
|
||||
self.assert_image_similar(lena(), out, 2)
|
||||
|
||||
self.assert_image_similar(hopper(), out, 2)
|
||||
|
||||
def test_profile_tobytes(self):
|
||||
from io import BytesIO
|
||||
|
@ -231,14 +229,12 @@ class TestImageCms(PillowTestCase):
|
|||
|
||||
# not the same bytes as the original icc_profile,
|
||||
# but it does roundtrip
|
||||
self.assertEqual(p.tobytes(),p2.tobytes())
|
||||
self.assertEqual(p.tobytes(), p2.tobytes())
|
||||
self.assertEqual(ImageCms.getProfileName(p),
|
||||
ImageCms.getProfileName(p2))
|
||||
self.assertEqual(ImageCms.getProfileDescription(p),
|
||||
ImageCms.getProfileDescription(p2))
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user