mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 01:46:18 +03:00
Replace lena.gif with hopper.gif
This commit is contained in:
parent
b248dcd019
commit
d7f7965aa2
Binary file not shown.
Before Width: | Height: | Size: 16 KiB |
|
@ -1,4 +1,4 @@
|
|||
from helper import unittest, PillowTestCase, lena, netpbm_available
|
||||
from helper import unittest, PillowTestCase, hopper, netpbm_available
|
||||
|
||||
from PIL import Image
|
||||
from PIL import GifImagePlugin
|
||||
|
@ -6,8 +6,9 @@ from PIL import GifImagePlugin
|
|||
codecs = dir(Image.core)
|
||||
|
||||
# sample gif stream
|
||||
file = "Tests/images/lena.gif"
|
||||
with open(file, "rb") as f:
|
||||
TEST_GIF = "Tests/images/hopper.gif"
|
||||
|
||||
with open(TEST_GIF, "rb") as f:
|
||||
data = f.read()
|
||||
|
||||
|
||||
|
@ -18,7 +19,7 @@ class TestFileGif(PillowTestCase):
|
|||
self.skipTest("gif support not available") # can this happen?
|
||||
|
||||
def test_sanity(self):
|
||||
im = Image.open(file)
|
||||
im = Image.open(TEST_GIF)
|
||||
im.load()
|
||||
self.assertEqual(im.mode, "P")
|
||||
self.assertEqual(im.size, (128, 128))
|
||||
|
@ -45,7 +46,7 @@ class TestFileGif(PillowTestCase):
|
|||
|
||||
def test_roundtrip(self):
|
||||
out = self.tempfile('temp.gif')
|
||||
im = lena()
|
||||
im = hopper()
|
||||
im.save(out)
|
||||
reread = Image.open(out)
|
||||
|
||||
|
@ -54,17 +55,17 @@ class TestFileGif(PillowTestCase):
|
|||
def test_roundtrip2(self):
|
||||
# see https://github.com/python-pillow/Pillow/issues/403
|
||||
out = self.tempfile('temp.gif')
|
||||
im = Image.open('Tests/images/lena.gif')
|
||||
im = Image.open(TEST_GIF)
|
||||
im2 = im.copy()
|
||||
im2.save(out)
|
||||
reread = Image.open(out)
|
||||
|
||||
self.assert_image_similar(reread.convert('RGB'), lena(), 50)
|
||||
self.assert_image_similar(reread.convert('RGB'), hopper(), 50)
|
||||
|
||||
def test_palette_handling(self):
|
||||
# see https://github.com/python-pillow/Pillow/issues/513
|
||||
|
||||
im = Image.open('Tests/images/lena.gif')
|
||||
im = Image.open(TEST_GIF)
|
||||
im = im.convert('RGB')
|
||||
|
||||
im = im.resize((100, 100), Image.ANTIALIAS)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from helper import unittest, PillowTestCase, lena
|
||||
from helper import unittest, PillowTestCase, hopper
|
||||
|
||||
from PIL import Image
|
||||
|
||||
|
@ -9,21 +9,21 @@ class TestImageLoad(PillowTestCase):
|
|||
|
||||
def test_sanity(self):
|
||||
|
||||
im = lena()
|
||||
im = hopper()
|
||||
|
||||
pix = im.load()
|
||||
|
||||
self.assertEqual(pix[0, 0], (223, 162, 133))
|
||||
self.assertEqual(pix[0, 0], (20, 20, 70))
|
||||
|
||||
def test_close(self):
|
||||
im = Image.open("Tests/images/lena.gif")
|
||||
im = Image.open("Tests/images/hopper.gif")
|
||||
im.close()
|
||||
self.assertRaises(ValueError, lambda: im.load())
|
||||
self.assertRaises(ValueError, lambda: im.getpixel((0, 0)))
|
||||
|
||||
def test_contextmanager(self):
|
||||
fn = None
|
||||
with Image.open("Tests/images/lena.gif") as im:
|
||||
with Image.open("Tests/images/hopper.gif") as im:
|
||||
fn = im.fp.fileno()
|
||||
os.fstat(fn)
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@ import shutil
|
|||
|
||||
from PIL import Image, JpegImagePlugin, GifImagePlugin
|
||||
|
||||
test_jpg = "Tests/images/lena.jpg"
|
||||
test_gif = "Tests/images/lena.gif"
|
||||
TEST_JPG = "Tests/images/hopper.jpg"
|
||||
TEST_GIF = "Tests/images/hopper.gif"
|
||||
|
||||
test_filenames = (
|
||||
"temp_';",
|
||||
|
@ -31,24 +31,24 @@ class TestShellInjection(PillowTestCase):
|
|||
def test_load_djpeg_filename(self):
|
||||
for filename in test_filenames:
|
||||
src_file = self.tempfile(filename)
|
||||
shutil.copy(test_jpg, src_file)
|
||||
shutil.copy(TEST_JPG, src_file)
|
||||
|
||||
im = Image.open(src_file)
|
||||
im.load_djpeg()
|
||||
|
||||
@unittest.skipUnless(cjpeg_available(), "cjpeg not available")
|
||||
def test_save_cjpeg_filename(self):
|
||||
im = Image.open(test_jpg)
|
||||
im = Image.open(TEST_JPG)
|
||||
self.assert_save_filename_check(im, JpegImagePlugin._save_cjpeg)
|
||||
|
||||
@unittest.skipUnless(netpbm_available(), "netpbm not available")
|
||||
def test_save_netpbm_filename_bmp_mode(self):
|
||||
im = Image.open(test_gif).convert("RGB")
|
||||
im = Image.open(TEST_GIF).convert("RGB")
|
||||
self.assert_save_filename_check(im, GifImagePlugin._save_netpbm)
|
||||
|
||||
@unittest.skipUnless(netpbm_available(), "netpbm not available")
|
||||
def test_save_netpbm_filename_l_mode(self):
|
||||
im = Image.open(test_gif).convert("L")
|
||||
im = Image.open(TEST_GIF).convert("L")
|
||||
self.assert_save_filename_check(im, GifImagePlugin._save_netpbm)
|
||||
|
||||
|
||||
|
|
10
selftest.py
10
selftest.py
|
@ -49,13 +49,13 @@ def testimage():
|
|||
|
||||
Or open existing files:
|
||||
|
||||
>>> im = Image.open(os.path.join(ROOT, "Tests/images/lena.gif"))
|
||||
>>> im = Image.open(os.path.join(ROOT, "Tests/images/hopper.gif"))
|
||||
>>> _info(im)
|
||||
('GIF', 'P', (128, 128))
|
||||
>>> _info(Image.open(os.path.join(ROOT, "Tests/images/lena.ppm")))
|
||||
>>> _info(Image.open(os.path.join(ROOT, "Tests/images/hopper.ppm")))
|
||||
('PPM', 'RGB', (128, 128))
|
||||
>>> try:
|
||||
... _info(Image.open(os.path.join(ROOT, "Tests/images/lena.jpg")))
|
||||
... _info(Image.open(os.path.join(ROOT, "Tests/images/hopper.jpg")))
|
||||
... except IOError as v:
|
||||
... print(v)
|
||||
('JPEG', 'RGB', (128, 128))
|
||||
|
@ -63,7 +63,7 @@ def testimage():
|
|||
PIL doesn't actually load the image data until it's needed,
|
||||
or you call the "load" method:
|
||||
|
||||
>>> im = Image.open(os.path.join(ROOT, "Tests/images/lena.ppm"))
|
||||
>>> im = Image.open(os.path.join(ROOT, "Tests/images/hopper.ppm"))
|
||||
>>> print(im.im) # internal image attribute
|
||||
None
|
||||
>>> a = im.load()
|
||||
|
@ -73,7 +73,7 @@ def testimage():
|
|||
You can apply many different operations on images. Most
|
||||
operations return a new image:
|
||||
|
||||
>>> im = Image.open(os.path.join(ROOT, "Tests/images/lena.ppm"))
|
||||
>>> im = Image.open(os.path.join(ROOT, "Tests/images/hopper.ppm"))
|
||||
>>> _info(im.convert("L"))
|
||||
(None, 'L', (128, 128))
|
||||
>>> _info(im.copy())
|
||||
|
|
Loading…
Reference in New Issue
Block a user