Merge pull request #887 from hugovk/hopper2a
Replace Lena with Hopper (Part I)
|  | @ -180,6 +180,26 @@ def tostring(im, format, **options): | |||
|     return out.getvalue() | ||||
| 
 | ||||
| 
 | ||||
| def hopper(mode="RGB", cache={}): | ||||
|     from PIL import Image | ||||
|     im = None | ||||
|     # FIXME: Implement caching to reduce reading from disk but so an original | ||||
|     # copy is returned each time and the cached image isn't modified by tests | ||||
|     # (for fast, isolated, repeatable tests). | ||||
|     # im = cache.get(mode) | ||||
|     if im is None: | ||||
|         if mode == "RGB": | ||||
|             im = Image.open("Tests/images/hopper.ppm") | ||||
|         elif mode == "F": | ||||
|             im = lena("L").convert(mode) | ||||
|         elif mode[:4] == "I;16": | ||||
|             im = lena("I").convert(mode) | ||||
|         else: | ||||
|             im = lena("RGB").convert(mode) | ||||
|     # cache[mode] = im | ||||
|     return im | ||||
| 
 | ||||
| 
 | ||||
| def lena(mode="RGB", cache={}): | ||||
|     from PIL import Image | ||||
|     im = None | ||||
|  |  | |||
| Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 40 KiB | 
							
								
								
									
										
											BIN
										
									
								
								Tests/images/hopper.bw
									
									
									
									
									
										Normal file
									
								
							
							
						
						
							
								
								
									
										
											BIN
										
									
								
								Tests/images/hopper.dcx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
							
								
								
									
										
											BIN
										
									
								
								Tests/images/hopper.gif
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 15 KiB | 
							
								
								
									
										
											BIN
										
									
								
								Tests/images/hopper.ico
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 1.1 KiB | 
							
								
								
									
										
											BIN
										
									
								
								Tests/images/hopper.jpg
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 6.3 KiB | 
							
								
								
									
										
											BIN
										
									
								
								Tests/images/hopper.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 30 KiB | 
							
								
								
									
										
											BIN
										
									
								
								Tests/images/hopper.ppm
									
									
									
									
									
										Normal file
									
								
							
							
						
						
							
								
								
									
										
											BIN
										
									
								
								Tests/images/hopper.ras
									
									
									
									
									
										Normal file
									
								
							
							
						
						
							
								
								
									
										
											BIN
										
									
								
								Tests/images/hopper.rgb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
							
								
								
									
										
											BIN
										
									
								
								Tests/images/hopper.spider
									
									
									
									
									
										Normal file
									
								
							
							
						
						
							
								
								
									
										
											BIN
										
									
								
								Tests/images/hopper.tar
									
									
									
									
									
										Normal file
									
								
							
							
						
						| Before Width: | Height: | Size: 16 KiB | 
| Before Width: | Height: | Size: 1.4 KiB | 
| Before Width: | Height: | Size: 37 KiB | 
|  | @ -1,9 +1,9 @@ | |||
| from helper import unittest, PillowTestCase, lena | ||||
| from helper import unittest, PillowTestCase, hopper | ||||
| 
 | ||||
| from PIL import Image, DcxImagePlugin | ||||
| 
 | ||||
| # Created with ImageMagick: convert lena.ppm lena.dcx | ||||
| TEST_FILE = "Tests/images/lena.dcx" | ||||
| # Created with ImageMagick: convert hopper.ppm hopper.dcx | ||||
| TEST_FILE = "Tests/images/hopper.dcx" | ||||
| 
 | ||||
| 
 | ||||
| class TestFileDcx(PillowTestCase): | ||||
|  | @ -17,7 +17,7 @@ class TestFileDcx(PillowTestCase): | |||
|         # Assert | ||||
|         self.assertEqual(im.size, (128, 128)) | ||||
|         self.assertIsInstance(im, DcxImagePlugin.DcxImageFile) | ||||
|         orig = lena() | ||||
|         orig = hopper() | ||||
|         self.assert_image_equal(im, orig) | ||||
| 
 | ||||
|     def test_tell(self): | ||||
|  |  | |||
|  | @ -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) | ||||
|  | @ -100,7 +101,7 @@ class TestFileGif(PillowTestCase): | |||
| 
 | ||||
|     @unittest.skipUnless(netpbm_available(), "netpbm not available") | ||||
|     def test_save_netpbm_bmp_mode(self): | ||||
|         img = Image.open(file).convert("RGB") | ||||
|         img = Image.open(TEST_GIF).convert("RGB") | ||||
| 
 | ||||
|         tempfile = self.tempfile("temp.gif") | ||||
|         GifImagePlugin._save_netpbm(img, 0, tempfile) | ||||
|  | @ -108,7 +109,7 @@ class TestFileGif(PillowTestCase): | |||
| 
 | ||||
|     @unittest.skipUnless(netpbm_available(), "netpbm not available") | ||||
|     def test_save_netpbm_l_mode(self): | ||||
|         img = Image.open(file).convert("L") | ||||
|         img = Image.open(TEST_GIF).convert("L") | ||||
| 
 | ||||
|         tempfile = self.tempfile("temp.gif") | ||||
|         GifImagePlugin._save_netpbm(img, 0, tempfile) | ||||
|  |  | |||
|  | @ -3,14 +3,14 @@ from helper import unittest, PillowTestCase | |||
| from PIL import Image | ||||
| 
 | ||||
| # sample ppm stream | ||||
| file = "Tests/images/lena.ico" | ||||
| data = open(file, "rb").read() | ||||
| TEST_ICO_FILE = "Tests/images/hopper.ico" | ||||
| TEST_DATA = open(TEST_ICO_FILE, "rb").read() | ||||
| 
 | ||||
| 
 | ||||
| class TestFileIco(PillowTestCase): | ||||
| 
 | ||||
|     def test_sanity(self): | ||||
|         im = Image.open(file) | ||||
|         im = Image.open(TEST_ICO_FILE) | ||||
|         im.load() | ||||
|         self.assertEqual(im.mode, "RGBA") | ||||
|         self.assertEqual(im.size, (16, 16)) | ||||
|  |  | |||
|  | @ -1,4 +1,4 @@ | |||
| from helper import unittest, PillowTestCase, lena | ||||
| from helper import unittest, PillowTestCase, hopper | ||||
| 
 | ||||
| from io import BytesIO | ||||
| 
 | ||||
|  | @ -10,8 +10,8 @@ codecs = dir(Image.core) | |||
| 
 | ||||
| # sample png stream | ||||
| 
 | ||||
| file = "Tests/images/lena.png" | ||||
| data = open(file, "rb").read() | ||||
| TEST_PNG_FILE = "Tests/images/hopper.png" | ||||
| TEST_DATA = open(TEST_PNG_FILE, "rb").read() | ||||
| 
 | ||||
| # stuff to create inline PNG images | ||||
| 
 | ||||
|  | @ -58,7 +58,7 @@ class TestFilePng(PillowTestCase): | |||
| 
 | ||||
|         file = self.tempfile("temp.png") | ||||
| 
 | ||||
|         lena("RGB").save(file) | ||||
|         hopper("RGB").save(file) | ||||
| 
 | ||||
|         im = Image.open(file) | ||||
|         im.load() | ||||
|  | @ -66,19 +66,19 @@ class TestFilePng(PillowTestCase): | |||
|         self.assertEqual(im.size, (128, 128)) | ||||
|         self.assertEqual(im.format, "PNG") | ||||
| 
 | ||||
|         lena("1").save(file) | ||||
|         hopper("1").save(file) | ||||
|         im = Image.open(file) | ||||
| 
 | ||||
|         lena("L").save(file) | ||||
|         hopper("L").save(file) | ||||
|         im = Image.open(file) | ||||
| 
 | ||||
|         lena("P").save(file) | ||||
|         hopper("P").save(file) | ||||
|         im = Image.open(file) | ||||
| 
 | ||||
|         lena("RGB").save(file) | ||||
|         hopper("RGB").save(file) | ||||
|         im = Image.open(file) | ||||
| 
 | ||||
|         lena("I").save(file) | ||||
|         hopper("I").save(file) | ||||
|         im = Image.open(file) | ||||
| 
 | ||||
|     def test_broken(self): | ||||
|  | @ -237,17 +237,17 @@ class TestFilePng(PillowTestCase): | |||
|     def test_load_verify(self): | ||||
|         # Check open/load/verify exception (@PIL150) | ||||
| 
 | ||||
|         im = Image.open("Tests/images/lena.png") | ||||
|         im = Image.open(TEST_PNG_FILE) | ||||
|         im.verify() | ||||
| 
 | ||||
|         im = Image.open("Tests/images/lena.png") | ||||
|         im = Image.open(TEST_PNG_FILE) | ||||
|         im.load() | ||||
|         self.assertRaises(RuntimeError, lambda: im.verify()) | ||||
| 
 | ||||
|     def test_roundtrip_dpi(self): | ||||
|         # Check dpi roundtripping | ||||
| 
 | ||||
|         im = Image.open(file) | ||||
|         im = Image.open(TEST_PNG_FILE) | ||||
| 
 | ||||
|         im = roundtrip(im, dpi=(100, 100)) | ||||
|         self.assertEqual(im.info["dpi"], (100, 100)) | ||||
|  | @ -255,7 +255,7 @@ class TestFilePng(PillowTestCase): | |||
|     def test_roundtrip_text(self): | ||||
|         # Check text roundtripping | ||||
| 
 | ||||
|         im = Image.open(file) | ||||
|         im = Image.open(TEST_PNG_FILE) | ||||
| 
 | ||||
|         info = PngImagePlugin.PngInfo() | ||||
|         info.add_text("TXT", "VALUE") | ||||
|  | @ -338,7 +338,7 @@ class TestFilePng(PillowTestCase): | |||
| 
 | ||||
|     def test_trns_p(self): | ||||
|         # Check writing a transparency of 0, issue #528 | ||||
|         im = lena('P') | ||||
|         im = hopper('P') | ||||
|         im.info['transparency'] = 0 | ||||
| 
 | ||||
|         f = self.tempfile("temp.png") | ||||
|  | @ -360,7 +360,7 @@ class TestFilePng(PillowTestCase): | |||
| 
 | ||||
|     def test_roundtrip_icc_profile(self): | ||||
|         # check that we can roundtrip the icc profile | ||||
|         im = lena('RGB') | ||||
|         im = hopper('RGB') | ||||
| 
 | ||||
|         jpeg_image = Image.open('Tests/images/flower2.jpg') | ||||
|         expected_icc = jpeg_image.info['icc_profile'] | ||||
|  |  | |||
|  | @ -8,8 +8,8 @@ class TestFileSgi(PillowTestCase): | |||
|     def test_rgb(self): | ||||
|         # Arrange | ||||
|         # Created with ImageMagick then renamed: | ||||
|         # convert lena.ppm lena.sgi | ||||
|         test_file = "Tests/images/lena.rgb" | ||||
|         # convert hopper.ppm hopper.sgi | ||||
|         test_file = "Tests/images/hopper.rgb" | ||||
| 
 | ||||
|         # Act / Assert | ||||
|         self.assertRaises(ValueError, lambda: Image.open(test_file)) | ||||
|  | @ -17,8 +17,8 @@ class TestFileSgi(PillowTestCase): | |||
|     def test_l(self): | ||||
|         # Arrange | ||||
|         # Created with ImageMagick then renamed: | ||||
|         # convert lena.ppm -monochrome lena.sgi | ||||
|         test_file = "Tests/images/lena.bw" | ||||
|         # convert hopper.ppm -monochrome hopper.sgi | ||||
|         test_file = "Tests/images/hopper.bw" | ||||
| 
 | ||||
|         # Act / Assert | ||||
|         self.assertRaises(ValueError, lambda: Image.open(test_file)) | ||||
|  |  | |||
|  | @ -1,9 +1,9 @@ | |||
| from helper import unittest, PillowTestCase, lena | ||||
| from helper import unittest, PillowTestCase, hopper | ||||
| 
 | ||||
| from PIL import Image | ||||
| from PIL import SpiderImagePlugin | ||||
| 
 | ||||
| TEST_FILE = "Tests/images/lena.spider" | ||||
| TEST_FILE = "Tests/images/hopper.spider" | ||||
| 
 | ||||
| 
 | ||||
| class TestImageSpider(PillowTestCase): | ||||
|  | @ -18,7 +18,7 @@ class TestImageSpider(PillowTestCase): | |||
|     def test_save(self): | ||||
|         # Arrange | ||||
|         temp = self.tempfile('temp.spider') | ||||
|         im = lena() | ||||
|         im = hopper() | ||||
| 
 | ||||
|         # Act | ||||
|         im.save(temp, "SPIDER") | ||||
|  | @ -44,7 +44,7 @@ class TestImageSpider(PillowTestCase): | |||
| 
 | ||||
|     def test_loadImageSeries(self): | ||||
|         # Arrange | ||||
|         not_spider_file = "Tests/images/lena.ppm" | ||||
|         not_spider_file = "Tests/images/hopper.ppm" | ||||
|         file_list = [TEST_FILE, not_spider_file, "path/not_found.ext"] | ||||
| 
 | ||||
|         # Act | ||||
|  |  | |||
|  | @ -7,8 +7,8 @@ class TestFileSun(PillowTestCase): | |||
| 
 | ||||
|     def test_sanity(self): | ||||
|         # Arrange | ||||
|         # Created with ImageMagick: convert lena.ppm lena.ras | ||||
|         test_file = "Tests/images/lena.ras" | ||||
|         # Created with ImageMagick: convert hopper.jpg hopper.ras | ||||
|         test_file = "Tests/images/hopper.ras" | ||||
| 
 | ||||
|         # Act | ||||
|         im = Image.open(test_file) | ||||
|  |  | |||
|  | @ -4,8 +4,8 @@ from PIL import Image, TarIO | |||
| 
 | ||||
| codecs = dir(Image.core) | ||||
| 
 | ||||
| # sample ppm stream | ||||
| tarfile = "Tests/images/lena.tar" | ||||
| # Sample tar archive | ||||
| TEST_TAR_FILE = "Tests/images/hopper.tar" | ||||
| 
 | ||||
| 
 | ||||
| class TestFileTar(PillowTestCase): | ||||
|  | @ -16,7 +16,7 @@ class TestFileTar(PillowTestCase): | |||
| 
 | ||||
|     def test_sanity(self): | ||||
|         if "zip_decoder" in codecs: | ||||
|             tar = TarIO.TarIO(tarfile, 'lena.png') | ||||
|             tar = TarIO.TarIO(TEST_TAR_FILE, 'hopper.png') | ||||
|             im = Image.open(tar) | ||||
|             im.load() | ||||
|             self.assertEqual(im.mode, "RGB") | ||||
|  | @ -24,7 +24,7 @@ class TestFileTar(PillowTestCase): | |||
|             self.assertEqual(im.format, "PNG") | ||||
| 
 | ||||
|         if "jpeg_decoder" in codecs: | ||||
|             tar = TarIO.TarIO(tarfile, 'lena.jpg') | ||||
|             tar = TarIO.TarIO(TEST_TAR_FILE, 'hopper.jpg') | ||||
|             im = Image.open(tar) | ||||
|             im.load() | ||||
|             self.assertEqual(im.mode, "RGB") | ||||
|  |  | |||
|  | @ -1,4 +1,4 @@ | |||
| from helper import unittest, PillowTestCase, lena | ||||
| from helper import unittest, PillowTestCase, hopper | ||||
| 
 | ||||
| from PIL import Image | ||||
| import sys | ||||
|  | @ -58,7 +58,7 @@ class TestImage(PillowTestCase): | |||
| 
 | ||||
|     def test_expand_x(self): | ||||
|         # Arrange | ||||
|         im = lena() | ||||
|         im = hopper() | ||||
|         orig_size = im.size | ||||
|         xmargin = 5 | ||||
| 
 | ||||
|  | @ -71,7 +71,7 @@ class TestImage(PillowTestCase): | |||
| 
 | ||||
|     def test_expand_xy(self): | ||||
|         # Arrange | ||||
|         im = lena() | ||||
|         im = hopper() | ||||
|         orig_size = im.size | ||||
|         xmargin = 5 | ||||
|         ymargin = 3 | ||||
|  | @ -85,7 +85,7 @@ class TestImage(PillowTestCase): | |||
| 
 | ||||
|     def test_getbands(self): | ||||
|         # Arrange | ||||
|         im = lena() | ||||
|         im = hopper() | ||||
| 
 | ||||
|         # Act | ||||
|         bands = im.getbands() | ||||
|  | @ -95,7 +95,7 @@ class TestImage(PillowTestCase): | |||
| 
 | ||||
|     def test_getbbox(self): | ||||
|         # Arrange | ||||
|         im = lena() | ||||
|         im = hopper() | ||||
| 
 | ||||
|         # Act | ||||
|         bbox = im.getbbox() | ||||
|  | @ -185,7 +185,7 @@ class TestImage(PillowTestCase): | |||
| 
 | ||||
|     def test_effect_spread(self): | ||||
|         # Arrange | ||||
|         im = lena() | ||||
|         im = hopper() | ||||
|         distance = 10 | ||||
| 
 | ||||
|         # Act | ||||
|  | @ -194,7 +194,7 @@ class TestImage(PillowTestCase): | |||
|         # Assert | ||||
|         self.assertEqual(im.size, (128, 128)) | ||||
|         im3 = Image.open('Tests/images/effect_spread.png') | ||||
|         self.assert_image_similar(im2, im3, 80) | ||||
|         self.assert_image_similar(im2, im3, 110) | ||||
| 
 | ||||
| if __name__ == '__main__': | ||||
|     unittest.main() | ||||
|  |  | |||
|  | @ -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) | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
							
								
								
									
										14
									
								
								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()) | ||||
|  | @ -89,9 +89,9 @@ def testimage(): | |||
|     >>> len(im.getdata()) | ||||
|     16384 | ||||
|     >>> im.getextrema() | ||||
|     ((61, 255), (26, 234), (44, 223)) | ||||
|     ((0, 255), (0, 255), (0, 255)) | ||||
|     >>> im.getpixel((0, 0)) | ||||
|     (223, 162, 133) | ||||
|     (20, 20, 70) | ||||
|     >>> len(im.getprojection()) | ||||
|     2 | ||||
|     >>> len(im.histogram()) | ||||
|  |  | |||