diff --git a/PIL/Image.py b/PIL/Image.py index a7491fd83..54291fbdd 100644 --- a/PIL/Image.py +++ b/PIL/Image.py @@ -867,7 +867,17 @@ class Image: trns = trns_im.getpixel((0,0)) elif self.mode == 'P' and mode == 'RGBA': + t = self.info['transparency'] delete_trns = True + + if isinstance(t, bytes): + self.im.putpalettealphas(t) + elif isinstance(t, int): + self.im.putpalettealpha(t,0) + else: + raise ValueError("Transparency for P mode should" + + " be bytes or int") + if mode == "P" and palette == ADAPTIVE: im = self.im.quantize(colors) diff --git a/Tests/bench_cffi_access.py b/Tests/bench_cffi_access.py index 8aa322aff..769396f53 100644 --- a/Tests/bench_cffi_access.py +++ b/Tests/bench_cffi_access.py @@ -1,4 +1,4 @@ -from helper import * +from helper import unittest, PillowTestCase, hopper # Not running this test by default. No DOS against Travis CI. @@ -39,7 +39,7 @@ def timer(func, label, *args): class BenchCffiAccess(PillowTestCase): def test_direct(self): - im = lena() + im = hopper() im.load() # im = Image.new( "RGB", (2000, 2000), (1, 3, 2)) caccess = im.im.pixel_access(False) diff --git a/Tests/bench_get.py b/Tests/bench_get.py index 8a1331d39..8f786acf0 100644 --- a/Tests/bench_get.py +++ b/Tests/bench_get.py @@ -6,7 +6,7 @@ import timeit def bench(mode): - im = helper.lena(mode) + im = helper.hopper(mode) get = im.im.getpixel xy = 50, 50 # position shouldn't really matter t0 = timeit.default_timer() diff --git a/Tests/helper.py b/Tests/helper.py index 637e77f9c..3d875983e 100644 --- a/Tests/helper.py +++ b/Tests/helper.py @@ -180,6 +180,7 @@ def tostring(im, format, **options): return out.getvalue() +# Note: hopper() should be used in place of lena(), which will be removed. def hopper(mode="RGB", cache={}): from PIL import Image im = None @@ -191,15 +192,16 @@ def hopper(mode="RGB", cache={}): if mode == "RGB": im = Image.open("Tests/images/hopper.ppm") elif mode == "F": - im = lena("L").convert(mode) + im = hopper("L").convert(mode) elif mode[:4] == "I;16": - im = lena("I").convert(mode) + im = hopper("I").convert(mode) else: - im = lena("RGB").convert(mode) + im = hopper("RGB").convert(mode) # cache[mode] = im return im +# Note: hopper() should be used instead lena(), which will be removed. def lena(mode="RGB", cache={}): from PIL import Image im = None diff --git a/Tests/images/hopper.ico b/Tests/images/hopper.ico index 0c6fd8c70..cd301823a 100644 Binary files a/Tests/images/hopper.ico and b/Tests/images/hopper.ico differ diff --git a/Tests/images/hopper.tif b/Tests/images/hopper.tif new file mode 100644 index 000000000..cb9ef0490 Binary files /dev/null and b/Tests/images/hopper.tif differ diff --git a/Tests/test_cffi.py b/Tests/test_cffi.py index b9f99976d..5599dbb48 100644 --- a/Tests/test_cffi.py +++ b/Tests/test_cffi.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper try: import cffi @@ -62,16 +62,16 @@ class TestCffi(PillowTestCase): self.assertEqual(access[(x, y)], caccess[(x, y)]) def test_get_vs_c(self): - rgb = lena('RGB') + rgb = hopper('RGB') rgb.load() self._test_get_access(rgb) - self._test_get_access(lena('RGBA')) - self._test_get_access(lena('L')) - self._test_get_access(lena('LA')) - self._test_get_access(lena('1')) - self._test_get_access(lena('P')) - # self._test_get_access(lena('PA')) # PA -- how do I make a PA image? - self._test_get_access(lena('F')) + self._test_get_access(hopper('RGBA')) + self._test_get_access(hopper('L')) + self._test_get_access(hopper('LA')) + self._test_get_access(hopper('1')) + self._test_get_access(hopper('P')) + # self._test_get_access(hopper('PA')) # PA -- how do I make a PA image? + self._test_get_access(hopper('F')) im = Image.new('I;16', (10, 10), 40000) self._test_get_access(im) @@ -104,16 +104,16 @@ class TestCffi(PillowTestCase): self.assertEqual(color, caccess[(x, y)]) def test_set_vs_c(self): - rgb = lena('RGB') + rgb = hopper('RGB') rgb.load() self._test_set_access(rgb, (255, 128, 0)) - self._test_set_access(lena('RGBA'), (255, 192, 128, 0)) - self._test_set_access(lena('L'), 128) - self._test_set_access(lena('LA'), (128, 128)) - self._test_set_access(lena('1'), 255) - self._test_set_access(lena('P'), 128) + self._test_set_access(hopper('RGBA'), (255, 192, 128, 0)) + self._test_set_access(hopper('L'), 128) + self._test_set_access(hopper('LA'), (128, 128)) + self._test_set_access(hopper('1'), 255) + self._test_set_access(hopper('P'), 128) # self._test_set_access(i, (128, 128)) #PA -- undone how to make - self._test_set_access(lena('F'), 1024.0) + self._test_set_access(hopper('F'), 1024.0) im = Image.new('I;16', (10, 10), 40000) self._test_set_access(im, 45000) diff --git a/Tests/test_decompression_bomb.py b/Tests/test_decompression_bomb.py index 0803732ce..ae9aebfa8 100644 --- a/Tests/test_decompression_bomb.py +++ b/Tests/test_decompression_bomb.py @@ -2,7 +2,7 @@ from helper import unittest, PillowTestCase from PIL import Image -test_file = "Tests/images/lena.ppm" +TEST_FILE = "Tests/images/hopper.ppm" ORIGINAL_LIMIT = Image.MAX_IMAGE_PIXELS @@ -15,7 +15,7 @@ class TestDecompressionBomb(PillowTestCase): def test_no_warning_small_file(self): # Implicit assert: no warning. # A warning would cause a failure. - Image.open(test_file) + Image.open(TEST_FILE) def test_no_warning_no_limit(self): # Arrange @@ -26,7 +26,7 @@ class TestDecompressionBomb(PillowTestCase): # Act / Assert # Implicit assert: no warning. # A warning would cause a failure. - Image.open(test_file) + Image.open(TEST_FILE) def test_warning(self): # Arrange @@ -37,7 +37,7 @@ class TestDecompressionBomb(PillowTestCase): # Act / Assert self.assert_warning( Image.DecompressionBombWarning, - lambda: Image.open(test_file)) + lambda: Image.open(TEST_FILE)) if __name__ == '__main__': unittest.main() diff --git a/Tests/test_file_bmp.py b/Tests/test_file_bmp.py index e04f3642c..69792fe12 100644 --- a/Tests/test_file_bmp.py +++ b/Tests/test_file_bmp.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image import io @@ -18,16 +18,16 @@ class TestFileBmp(PillowTestCase): self.assertEqual(reloaded.format, "BMP") def test_sanity(self): - self.roundtrip(lena()) + self.roundtrip(hopper()) - self.roundtrip(lena("1")) - self.roundtrip(lena("L")) - self.roundtrip(lena("P")) - self.roundtrip(lena("RGB")) + self.roundtrip(hopper("1")) + self.roundtrip(hopper("L")) + self.roundtrip(hopper("P")) + self.roundtrip(hopper("RGB")) def test_save_to_bytes(self): output = io.BytesIO() - im = lena() + im = hopper() im.save(output, "BMP") output.seek(0) @@ -41,7 +41,7 @@ class TestFileBmp(PillowTestCase): dpi = (72, 72) output = io.BytesIO() - im = lena() + im = hopper() im.save(output, "BMP", dpi=dpi) output.seek(0) diff --git a/Tests/test_file_iptc.py b/Tests/test_file_iptc.py index bd331e5b2..14eb135aa 100644 --- a/Tests/test_file_iptc.py +++ b/Tests/test_file_iptc.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image, IptcImagePlugin @@ -21,7 +21,7 @@ class TestFileIptc(PillowTestCase): def test_getiptcinfo_jpg_none(self): # Arrange - im = lena() + im = hopper() # Act iptc = IptcImagePlugin.getiptcinfo(im) diff --git a/Tests/test_file_libtiff.py b/Tests/test_file_libtiff.py index bdac5f300..e5d95d75c 100644 --- a/Tests/test_file_libtiff.py +++ b/Tests/test_file_libtiff.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena, py3 +from helper import unittest, PillowTestCase, hopper, py3 import os @@ -268,7 +268,7 @@ class TestFileLibTiff(LibTiffTestCase): self.assert_image_equal(im, im2) def test_compressions(self): - im = lena('RGB') + im = hopper('RGB') out = self.tempfile('temp.tif') for compression in ('packbits', 'tiff_lzw'): @@ -281,7 +281,7 @@ class TestFileLibTiff(LibTiffTestCase): self.assert_image_similar(im, im2, 30) def test_cmyk_save(self): - im = lena('CMYK') + im = hopper('CMYK') out = self.tempfile('temp.tif') im.save(out, compression='tiff_adobe_deflate') @@ -293,7 +293,7 @@ class TestFileLibTiff(LibTiffTestCase): to output on stderr from the error thrown by libtiff. We need to capture that but not now""" - im = lena('RGB') + im = hopper('RGB') out = self.tempfile('temp.tif') self.assertRaises( @@ -332,12 +332,12 @@ class TestFileLibTiff(LibTiffTestCase): self.assertFalse(im.tag.next) self.assertEqual(im.size, (20,20)) self.assertEqual(im.convert('RGB').getpixel((0,0)), (0,0,255)) - + TiffImagePlugin.READ_LIBTIFF = False def test__next(self): TiffImagePlugin.READ_LIBTIFF = True - im = Image.open('Tests/images/lena.tif') + im = Image.open('Tests/images/hopper.tif') self.assertFalse(im.tag.next) im.load() self.assertFalse(im.tag.next) diff --git a/Tests/test_file_msp.py b/Tests/test_file_msp.py index a64faad10..c080247a0 100644 --- a/Tests/test_file_msp.py +++ b/Tests/test_file_msp.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image @@ -9,7 +9,7 @@ class TestFileMsp(PillowTestCase): file = self.tempfile("temp.msp") - lena("1").save(file) + hopper("1").save(file) im = Image.open(file) im.load() diff --git a/Tests/test_file_palm.py b/Tests/test_file_palm.py index 388df0237..7af3e16bd 100644 --- a/Tests/test_file_palm.py +++ b/Tests/test_file_palm.py @@ -1,14 +1,14 @@ -from helper import unittest, PillowTestCase, lena, imagemagick_available +from helper import unittest, PillowTestCase, hopper, imagemagick_available import os.path class TestFilePalm(PillowTestCase): _roundtrip = imagemagick_available() - + def helper_save_as_palm(self, mode): # Arrange - im = lena(mode) + im = hopper(mode) outfile = self.tempfile("temp_" + mode + ".palm") # Act @@ -21,14 +21,14 @@ class TestFilePalm(PillowTestCase): def roundtrip(self, mode): if not self._roundtrip: return - - im = lena(mode) + + im = hopper(mode) outfile = self.tempfile("temp.palm") im.save(outfile) converted = self.open_withImagemagick(outfile) self.assert_image_equal(converted, im) - + def test_monochrome(self): # Arrange @@ -46,7 +46,7 @@ class TestFilePalm(PillowTestCase): self.helper_save_as_palm(mode) self.skipKnownBadTest("Palm P image is wrong") self.roundtrip(mode) - + def test_rgb_ioerror(self): # Arrange mode = "RGB" diff --git a/Tests/test_file_pcx.py b/Tests/test_file_pcx.py index f278bd91d..36d6e0315 100644 --- a/Tests/test_file_pcx.py +++ b/Tests/test_file_pcx.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image @@ -17,7 +17,7 @@ class TestFilePcx(PillowTestCase): def test_sanity(self): for mode in ('1', 'L', 'P', 'RGB'): - self._roundtrip(lena(mode)) + self._roundtrip(hopper(mode)) def test_odd(self): # see issue #523, odd sized images should have a stride that's even. @@ -26,7 +26,7 @@ class TestFilePcx(PillowTestCase): for mode in ('1', 'L', 'P', 'RGB'): # larger, odd sized images are better here to ensure that # we handle interrupted scan lines properly. - self._roundtrip(lena(mode).resize((511, 511))) + self._roundtrip(hopper(mode).resize((511, 511))) def test_pil184(self): # Check reading of files where xmin/xmax is not zero. diff --git a/Tests/test_file_pdf.py b/Tests/test_file_pdf.py index 689302bb5..9424bc09d 100644 --- a/Tests/test_file_pdf.py +++ b/Tests/test_file_pdf.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper import os.path @@ -7,7 +7,7 @@ class TestFilePdf(PillowTestCase): def helper_save_as_pdf(self, mode): # Arrange - im = lena(mode) + im = hopper(mode) outfile = self.tempfile("temp_" + mode + ".pdf") # Act diff --git a/Tests/test_file_png.py b/Tests/test_file_png.py index 32dc10cd1..b8f5ceb08 100644 --- a/Tests/test_file_png.py +++ b/Tests/test_file_png.py @@ -347,7 +347,8 @@ class TestFilePng(PillowTestCase): im2 = Image.open(f) self.assertIn('transparency', im2.info) - self.assert_image_equal(im2.convert('RGBA'), im.convert('RGBA')) + self.assert_image_equal(im2.convert('RGBA'), + im.convert('RGBA')) def test_save_icc_profile_none(self): # check saving files with an ICC profile set to None (omit profile) diff --git a/Tests/test_file_ppm.py b/Tests/test_file_ppm.py index e1f1537d2..3731fd9b1 100644 --- a/Tests/test_file_ppm.py +++ b/Tests/test_file_ppm.py @@ -3,7 +3,7 @@ from helper import unittest, PillowTestCase from PIL import Image # sample ppm stream -file = "Tests/images/lena.ppm" +file = "Tests/images/hopper.ppm" data = open(file, "rb").read() diff --git a/Tests/test_file_tiff.py b/Tests/test_file_tiff.py index 464f1c314..cf809d5d0 100644 --- a/Tests/test_file_tiff.py +++ b/Tests/test_file_tiff.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena, py3 +from helper import unittest, PillowTestCase, hopper, py3 from PIL import Image, TiffImagePlugin @@ -9,7 +9,7 @@ class TestFileTiff(PillowTestCase): file = self.tempfile("temp.tif") - lena("RGB").save(file) + hopper("RGB").save(file) im = Image.open(file) im.load() @@ -17,19 +17,19 @@ class TestFileTiff(PillowTestCase): self.assertEqual(im.size, (128, 128)) self.assertEqual(im.format, "TIFF") - 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_mac_tiff(self): @@ -158,14 +158,14 @@ class TestFileTiff(PillowTestCase): im.seek(2) im.load() self.assertEqual(im.size, (20,20)) - self.assertEqual(im.convert('RGB').getpixel((0,0)), (0,0,255)) + self.assertEqual(im.convert('RGB').getpixel((0,0)), (0,0,255)) def test_multipage_last_frame(self): im = Image.open('Tests/images/multipage-lastframe.tif') im.load() self.assertEqual(im.size, (20,20)) - self.assertEqual(im.convert('RGB').getpixel((0,0)), (0,0,255)) - + self.assertEqual(im.convert('RGB').getpixel((0,0)), (0,0,255)) + def test___str__(self): # Arrange diff --git a/Tests/test_file_tiff_metadata.py b/Tests/test_file_tiff_metadata.py index 4cebb56e2..afbb23e4d 100644 --- a/Tests/test_file_tiff_metadata.py +++ b/Tests/test_file_tiff_metadata.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image, TiffImagePlugin, TiffTags @@ -13,7 +13,7 @@ class TestFileTiffMetadata(PillowTestCase): data. https://github.com/python-pillow/Pillow/issues/291 """ - img = lena() + img = hopper() textdata = "This is some arbitrary metadata for a text field" info = TiffImagePlugin.ImageFileDirectory() @@ -63,7 +63,7 @@ class TestFileTiffMetadata(PillowTestCase): def test_write_metadata(self): """ Test metadata writing through the python code """ - img = Image.open('Tests/images/lena.tif') + img = Image.open('Tests/images/hopper.tif') f = self.tempfile('temp.tiff') img.save(f, tiffinfo=img.tag) diff --git a/Tests/test_file_webp_alpha.py b/Tests/test_file_webp_alpha.py index 5f8f653cf..d6c5be450 100644 --- a/Tests/test_file_webp_alpha.py +++ b/Tests/test_file_webp_alpha.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image @@ -40,7 +40,7 @@ class TestFileWebpAlpha(PillowTestCase): temp_file = self.tempfile("temp.webp") # temp_file = "temp.webp" - pil_image = lena('RGBA') + pil_image = hopper('RGBA') mask = Image.new("RGBA", (64, 64), (128, 128, 128, 128)) # Add some partially transparent bits: diff --git a/Tests/test_file_webp_lossless.py b/Tests/test_file_webp_lossless.py index 662ad1117..52a461a74 100644 --- a/Tests/test_file_webp_lossless.py +++ b/Tests/test_file_webp_lossless.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image @@ -23,7 +23,7 @@ class TestFileWebpLossless(PillowTestCase): def test_write_lossless_rgb(self): temp_file = self.tempfile("temp.webp") - lena("RGB").save(temp_file, lossless=True) + hopper("RGB").save(temp_file, lossless=True) image = Image.open(temp_file) image.load() @@ -34,7 +34,7 @@ class TestFileWebpLossless(PillowTestCase): image.load() image.getdata() - self.assert_image_equal(image, lena("RGB")) + self.assert_image_equal(image, hopper("RGB")) if __name__ == '__main__': diff --git a/Tests/test_format_hsv.py b/Tests/test_format_hsv.py index 03603aa9b..c571e98ee 100644 --- a/Tests/test_format_hsv.py +++ b/Tests/test_format_hsv.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image @@ -15,7 +15,7 @@ class TestFormatHSV(PillowTestCase): def tuple_to_ints(self, tp): x,y,z = tp return (int(x*255.0), int(y*255.0), int(z*255.0)) - + def test_sanity(self): im = Image.new('HSV', (100,100)) @@ -24,7 +24,7 @@ class TestFormatHSV(PillowTestCase): w90 = w.rotate(90) (px, h) = w.size - + r = Image.new('L', (px*3,h)) g = r.copy() b = r.copy() @@ -45,12 +45,12 @@ class TestFormatHSV(PillowTestCase): #print (("%d, %d -> "% (int(.75*px),int(.25*px))) + \ # "(%s, %s, %s)"%img.getpixel((.75*px, .25*px))) return img - + def to_xxx_colorsys(self, im, func, mode): # convert the hard way using the library colorsys routines. - + (r,g,b) = im.split() - + if bytes is str: conv_func = self.str_to_float else: @@ -69,9 +69,9 @@ class TestFormatHSV(PillowTestCase): new_bytes = b''.join(chr(h)+chr(s)+chr(v) for (h,s,v) in converted) else: new_bytes = b''.join(bytes(chr(h)+chr(s)+chr(v), 'latin-1') for (h,s,v) in converted) - + hsv = Image.frombytes(mode,r.size, new_bytes) - + return hsv def to_hsv_colorsys(self, im): @@ -87,7 +87,7 @@ class TestFormatHSV(PillowTestCase): #print (im.getpixel((448, 64))) #print (comparable.getpixel((448, 64))) - + #print(im.split()[0].histogram()) #print(comparable.split()[0].histogram()) @@ -110,25 +110,25 @@ class TestFormatHSV(PillowTestCase): #comparable.split()[0].show() #print (im.getpixel((192, 64))) #print (comparable.getpixel((192, 64))) - + self.assert_image_similar(im.split()[0], comparable.split()[0], 3, "R conversion is wrong") self.assert_image_similar(im.split()[1], comparable.split()[1], 3, "G conversion is wrong") self.assert_image_similar(im.split()[2], comparable.split()[2], 3, "B conversion is wrong") - - + + def test_convert(self): - im = lena('RGB').convert('HSV') - comparable = self.to_hsv_colorsys(lena('RGB')) + im = hopper('RGB').convert('HSV') + comparable = self.to_hsv_colorsys(hopper('RGB')) # print ([ord(x) for x in im.split()[0].tobytes()[:80]]) # print ([ord(x) for x in comparable.split()[0].tobytes()[:80]]) # print(im.split()[0].histogram()) # print(comparable.split()[0].histogram()) - + self.assert_image_similar(im.split()[0], comparable.split()[0], 1, "Hue conversion is wrong") self.assert_image_similar(im.split()[1], comparable.split()[1], @@ -138,10 +138,10 @@ class TestFormatHSV(PillowTestCase): def test_hsv_to_rgb(self): - comparable = self.to_hsv_colorsys(lena('RGB')) + comparable = self.to_hsv_colorsys(hopper('RGB')) converted = comparable.convert('RGB') comparable = self.to_rgb_colorsys(comparable) - + # print(converted.split()[1].histogram()) # print(target.split()[1].histogram()) @@ -156,8 +156,8 @@ class TestFormatHSV(PillowTestCase): self.assert_image_similar(converted.split()[2], comparable.split()[2], 3, "B conversion is wrong") - - + + diff --git a/Tests/test_image_array.py b/Tests/test_image_array.py index c5e49fc39..0899afd02 100644 --- a/Tests/test_image_array.py +++ b/Tests/test_image_array.py @@ -1,8 +1,8 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image -im = lena().resize((128, 100)) +im = hopper().resize((128, 100)) class TestImageArray(PillowTestCase): diff --git a/Tests/test_image_convert.py b/Tests/test_image_convert.py index 01a80732b..8197a66e0 100644 --- a/Tests/test_image_convert.py +++ b/Tests/test_image_convert.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image @@ -15,13 +15,13 @@ class TestImageConvert(PillowTestCase): modes = "1", "L", "I", "F", "RGB", "RGBA", "RGBX", "CMYK", "YCbCr" for mode in modes: - im = lena(mode) + im = hopper(mode) for mode in modes: convert(im, mode) def test_default(self): - im = lena("P") + im = hopper("P") self.assert_image(im, "P", im.size) im = im.convert() self.assert_image(im, "RGB", im.size) @@ -36,7 +36,7 @@ class TestImageConvert(PillowTestCase): self.assertEqual(orig, converted) def test_8bit(self): - im = Image.open('Tests/images/lena.jpg') + im = Image.open('Tests/images/hopper.jpg') self._test_float_conversion(im.convert('L')) def test_16bit(self): @@ -48,8 +48,8 @@ class TestImageConvert(PillowTestCase): self._test_float_conversion(im.convert('I')) def test_rgba_p(self): - im = lena('RGBA') - im.putalpha(lena('L')) + im = hopper('RGBA') + im.putalpha(hopper('L')) converted = im.convert('P') comparable = converted.convert('RGBA') @@ -57,7 +57,7 @@ class TestImageConvert(PillowTestCase): self.assert_image_similar(im, comparable, 20) def test_trns_p(self): - im = lena('P') + im = hopper('P') im.info['transparency'] = 0 f = self.tempfile('temp.png') @@ -74,7 +74,7 @@ class TestImageConvert(PillowTestCase): def test_trns_p_rgba(self): # Arrange - im = lena('P') + im = hopper('P') im.info['transparency'] = 128 # Act @@ -84,7 +84,7 @@ class TestImageConvert(PillowTestCase): self.assertNotIn('transparency', rgba.info) def test_trns_l(self): - im = lena('L') + im = hopper('L') im.info['transparency'] = 128 f = self.tempfile('temp.png') @@ -104,7 +104,7 @@ class TestImageConvert(PillowTestCase): p.save(f) def test_trns_RGB(self): - im = lena('RGB') + im = hopper('RGB') im.info['transparency'] = im.getpixel((0, 0)) f = self.tempfile('temp.png') diff --git a/Tests/test_image_copy.py b/Tests/test_image_copy.py index a7882db94..4b0905af3 100644 --- a/Tests/test_image_copy.py +++ b/Tests/test_image_copy.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image @@ -7,7 +7,7 @@ class TestImageCopy(PillowTestCase): def test_copy(self): def copy(mode): - im = lena(mode) + im = hopper(mode) out = im.copy() self.assertEqual(out.mode, mode) self.assertEqual(out.size, im.size) diff --git a/Tests/test_image_crop.py b/Tests/test_image_crop.py index da93fe7c8..29ff2bc2a 100644 --- a/Tests/test_image_crop.py +++ b/Tests/test_image_crop.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image @@ -7,7 +7,7 @@ class TestImageCrop(PillowTestCase): def test_crop(self): def crop(mode): - out = lena(mode).crop((50, 50, 100, 100)) + out = hopper(mode).crop((50, 50, 100, 100)) self.assertEqual(out.mode, mode) self.assertEqual(out.size, (50, 50)) for mode in "1", "P", "L", "RGB", "I", "F": diff --git a/Tests/test_image_draft.py b/Tests/test_image_draft.py index a76b8d266..68676687c 100644 --- a/Tests/test_image_draft.py +++ b/Tests/test_image_draft.py @@ -2,13 +2,13 @@ from helper import unittest, PillowTestCase, fromstring, tostring from PIL import Image -codecs = dir(Image.core) -filename = "Tests/images/lena.jpg" -data = tostring(Image.open(filename).resize((512, 512)), "JPEG") +CODECS = dir(Image.core) +FILENAME = "Tests/images/hopper.jpg" +DATA = tostring(Image.open(FILENAME).resize((512, 512)), "JPEG") def draft(mode, size): - im = fromstring(data) + im = fromstring(DATA) im.draft(mode, size) return im @@ -16,7 +16,7 @@ def draft(mode, size): class TestImageDraft(PillowTestCase): def setUp(self): - if "jpeg_encoder" not in codecs or "jpeg_decoder" not in codecs: + if "jpeg_encoder" not in CODECS or "jpeg_decoder" not in CODECS: self.skipTest("jpeg support not available") def test_size(self): diff --git a/Tests/test_image_filter.py b/Tests/test_image_filter.py index 2452479cc..d29fd3dfd 100644 --- a/Tests/test_image_filter.py +++ b/Tests/test_image_filter.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image from PIL import ImageFilter @@ -9,7 +9,7 @@ class TestImageFilter(PillowTestCase): def test_sanity(self): def filter(filter): - im = lena("L") + im = hopper("L") out = im.filter(filter) self.assertEqual(out.mode, im.mode) self.assertEqual(out.size, im.size) diff --git a/Tests/test_image_frombytes.py b/Tests/test_image_frombytes.py index aad8046a1..3f9a2237f 100644 --- a/Tests/test_image_frombytes.py +++ b/Tests/test_image_frombytes.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image @@ -6,7 +6,7 @@ from PIL import Image class TestImageFromBytes(PillowTestCase): def test_sanity(self): - im1 = lena() + im1 = hopper() im2 = Image.frombytes(im1.mode, im1.size, im1.tobytes()) self.assert_image_equal(im1, im2) diff --git a/Tests/test_image_getbbox.py b/Tests/test_image_getbbox.py index 8d78195bd..3dc341aeb 100644 --- a/Tests/test_image_getbbox.py +++ b/Tests/test_image_getbbox.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image @@ -7,7 +7,7 @@ class TestImageGetBbox(PillowTestCase): def test_sanity(self): - bbox = lena().getbbox() + bbox = hopper().getbbox() self.assertIsInstance(bbox, tuple) def test_bbox(self): diff --git a/Tests/test_image_getcolors.py b/Tests/test_image_getcolors.py index d3e5a4989..8886762c7 100644 --- a/Tests/test_image_getcolors.py +++ b/Tests/test_image_getcolors.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper class TestImageGetColors(PillowTestCase): @@ -6,7 +6,7 @@ class TestImageGetColors(PillowTestCase): def test_getcolors(self): def getcolors(mode, limit=None): - im = lena(mode) + im = hopper(mode) if limit: colors = im.getcolors(limit) else: @@ -16,37 +16,36 @@ class TestImageGetColors(PillowTestCase): return None self.assertEqual(getcolors("1"), 2) - self.assertEqual(getcolors("L"), 193) - self.assertEqual(getcolors("I"), 193) - self.assertEqual(getcolors("F"), 193) - self.assertEqual(getcolors("P"), 54) # fixed palette + self.assertEqual(getcolors("L"), 255) + self.assertEqual(getcolors("I"), 255) + self.assertEqual(getcolors("F"), 255) + self.assertEqual(getcolors("P"), 90) # fixed palette self.assertEqual(getcolors("RGB"), None) self.assertEqual(getcolors("RGBA"), None) self.assertEqual(getcolors("CMYK"), None) self.assertEqual(getcolors("YCbCr"), None) self.assertEqual(getcolors("L", 128), None) - self.assertEqual(getcolors("L", 1024), 193) + self.assertEqual(getcolors("L", 1024), 255) self.assertEqual(getcolors("RGB", 8192), None) - self.assertEqual(getcolors("RGB", 16384), 14836) - self.assertEqual(getcolors("RGB", 100000), 14836) + self.assertEqual(getcolors("RGB", 16384), 10100) + self.assertEqual(getcolors("RGB", 100000), 10100) - self.assertEqual(getcolors("RGBA", 16384), 14836) - self.assertEqual(getcolors("CMYK", 16384), 14836) - self.assertEqual(getcolors("YCbCr", 16384), 11995) + self.assertEqual(getcolors("RGBA", 16384), 10100) + self.assertEqual(getcolors("CMYK", 16384), 10100) + self.assertEqual(getcolors("YCbCr", 16384), 9329) # -------------------------------------------------------------------- def test_pack(self): # Pack problems for small tables (@PIL209) - im = lena().quantize(3).convert("RGB") + im = hopper().quantize(3).convert("RGB") - expected = [ - (3236, (227, 183, 147)), - (6297, (143, 84, 81)), - (6851, (208, 143, 112))] + expected = [(4039, (172, 166, 181)), + (4385, (124, 113, 134)), + (7960, (31, 20, 33))] A = im.getcolors(maxcolors=2) self.assertEqual(A, None) diff --git a/Tests/test_image_getdata.py b/Tests/test_image_getdata.py index ff6659595..89bfda895 100644 --- a/Tests/test_image_getdata.py +++ b/Tests/test_image_getdata.py @@ -1,32 +1,32 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper class TestImageGetData(PillowTestCase): def test_sanity(self): - data = lena().getdata() + data = hopper().getdata() len(data) list(data) - self.assertEqual(data[0], (223, 162, 133)) + self.assertEqual(data[0], (20, 20, 70)) def test_roundtrip(self): def getdata(mode): - im = lena(mode).resize((32, 30)) + im = hopper(mode).resize((32, 30)) data = im.getdata() return data[0], len(data), len(list(data)) - self.assertEqual(getdata("1"), (255, 960, 960)) - self.assertEqual(getdata("L"), (176, 960, 960)) - self.assertEqual(getdata("I"), (176, 960, 960)) - self.assertEqual(getdata("F"), (176.0, 960, 960)) - self.assertEqual(getdata("RGB"), ((223, 162, 133), 960, 960)) - self.assertEqual(getdata("RGBA"), ((223, 162, 133, 255), 960, 960)) - self.assertEqual(getdata("CMYK"), ((32, 93, 122, 0), 960, 960)) - self.assertEqual(getdata("YCbCr"), ((176, 103, 160), 960, 960)) + self.assertEqual(getdata("1"), (0, 960, 960)) + self.assertEqual(getdata("L"), (25, 960, 960)) + self.assertEqual(getdata("I"), (25, 960, 960)) + self.assertEqual(getdata("F"), (25.0, 960, 960)) + self.assertEqual(getdata("RGB"), (((20, 20, 70), 960, 960))) + self.assertEqual(getdata("RGBA"), ((20, 20, 70, 255), 960, 960)) + self.assertEqual(getdata("CMYK"), ((235, 235, 185, 0), 960, 960)) + self.assertEqual(getdata("YCbCr"), ((25, 153, 123), 960, 960)) if __name__ == '__main__': diff --git a/Tests/test_image_getextrema.py b/Tests/test_image_getextrema.py index af7f7698a..84d932a98 100644 --- a/Tests/test_image_getextrema.py +++ b/Tests/test_image_getextrema.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper class TestImageGetExtrema(PillowTestCase): @@ -6,19 +6,19 @@ class TestImageGetExtrema(PillowTestCase): def test_extrema(self): def extrema(mode): - return lena(mode).getextrema() + return hopper(mode).getextrema() self.assertEqual(extrema("1"), (0, 255)) - self.assertEqual(extrema("L"), (40, 235)) - self.assertEqual(extrema("I"), (40, 235)) - self.assertEqual(extrema("F"), (40.0, 235.0)) - self.assertEqual(extrema("P"), (11, 218)) # fixed palette + self.assertEqual(extrema("L"), (0, 255)) + self.assertEqual(extrema("I"), (0, 255)) + self.assertEqual(extrema("F"), (0, 255)) + self.assertEqual(extrema("P"), (0, 225)) # fixed palette self.assertEqual( - extrema("RGB"), ((61, 255), (26, 234), (44, 223))) + extrema("RGB"), ((0, 255), (0, 255), (0, 255))) self.assertEqual( - extrema("RGBA"), ((61, 255), (26, 234), (44, 223), (255, 255))) + extrema("RGBA"), ((0, 255), (0, 255), (0, 255), (255, 255))) self.assertEqual( - extrema("CMYK"), ((0, 194), (21, 229), (32, 211), (0, 0))) + extrema("CMYK"), (((0, 255), (0, 255), (0, 255), (0, 0)))) if __name__ == '__main__': diff --git a/Tests/test_image_getim.py b/Tests/test_image_getim.py index d498d3923..e83439789 100644 --- a/Tests/test_image_getim.py +++ b/Tests/test_image_getim.py @@ -1,10 +1,10 @@ -from helper import unittest, PillowTestCase, lena, py3 +from helper import unittest, PillowTestCase, hopper, py3 class TestImageGetIm(PillowTestCase): def test_sanity(self): - im = lena() + im = hopper() type_repr = repr(type(im.getim())) if py3: diff --git a/Tests/test_image_getpalette.py b/Tests/test_image_getpalette.py index 0c399c432..1a673c73d 100644 --- a/Tests/test_image_getpalette.py +++ b/Tests/test_image_getpalette.py @@ -1,11 +1,11 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper class TestImageGetPalette(PillowTestCase): def test_palette(self): def palette(mode): - p = lena(mode).getpalette() + p = hopper(mode).getpalette() if p: return p[:10] return None diff --git a/Tests/test_image_getprojection.py b/Tests/test_image_getprojection.py index 262a21d4b..108c75b90 100644 --- a/Tests/test_image_getprojection.py +++ b/Tests/test_image_getprojection.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image @@ -7,7 +7,7 @@ class TestImageGetProjection(PillowTestCase): def test_sanity(self): - im = lena() + im = hopper() projection = im.getprojection() diff --git a/Tests/test_image_histogram.py b/Tests/test_image_histogram.py index 70f78a1fb..aa849a138 100644 --- a/Tests/test_image_histogram.py +++ b/Tests/test_image_histogram.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper class TestImageHistogram(PillowTestCase): @@ -6,18 +6,18 @@ class TestImageHistogram(PillowTestCase): def test_histogram(self): def histogram(mode): - h = lena(mode).histogram() + h = hopper(mode).histogram() return len(h), min(h), max(h) - self.assertEqual(histogram("1"), (256, 0, 8872)) - self.assertEqual(histogram("L"), (256, 0, 199)) - self.assertEqual(histogram("I"), (256, 0, 199)) - self.assertEqual(histogram("F"), (256, 0, 199)) - self.assertEqual(histogram("P"), (256, 0, 2912)) - self.assertEqual(histogram("RGB"), (768, 0, 285)) + self.assertEqual(histogram("1"), (256, 0, 10994)) + self.assertEqual(histogram("L"), (256, 0, 638)) + self.assertEqual(histogram("I"), (256, 0, 638)) + self.assertEqual(histogram("F"), (256, 0, 638)) + self.assertEqual(histogram("P"), (256, 0, 1871)) + self.assertEqual(histogram("RGB"), (768, 4, 675)) self.assertEqual(histogram("RGBA"), (1024, 0, 16384)) self.assertEqual(histogram("CMYK"), (1024, 0, 16384)) - self.assertEqual(histogram("YCbCr"), (768, 0, 741)) + self.assertEqual(histogram("YCbCr"), (768, 0, 1908)) if __name__ == '__main__': diff --git a/Tests/test_image_mode.py b/Tests/test_image_mode.py index 74ed9b7aa..6441c7d1b 100644 --- a/Tests/test_image_mode.py +++ b/Tests/test_image_mode.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image @@ -7,7 +7,7 @@ class TestImageMode(PillowTestCase): def test_sanity(self): - im = lena() + im = hopper() im.mode from PIL import ImageMode diff --git a/Tests/test_image_offset.py b/Tests/test_image_offset.py index 09f12266f..e5fe0bf47 100644 --- a/Tests/test_image_offset.py +++ b/Tests/test_image_offset.py @@ -1,11 +1,11 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper class TestImageOffset(PillowTestCase): def test_offset(self): - im1 = lena() + im1 = hopper() im2 = self.assert_warning(DeprecationWarning, lambda: im1.offset(10)) self.assertEqual(im1.getpixel((0, 0)), im2.getpixel((10, 10))) diff --git a/Tests/test_image_point.py b/Tests/test_image_point.py index 04054fa84..ee0165d09 100644 --- a/Tests/test_image_point.py +++ b/Tests/test_image_point.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper import sys @@ -6,7 +6,7 @@ import sys class TestImagePoint(PillowTestCase): def test_sanity(self): - im = lena() + im = hopper() self.assertRaises(ValueError, lambda: im.point(list(range(256)))) im.point(list(range(256))*3) @@ -28,19 +28,19 @@ class TestImagePoint(PillowTestCase): # see https://github.com/python-pillow/Pillow/issues/484 #self.skipKnownBadTest(msg="Too Slow on pypy", interpreter='pypy') - im = lena("I") + im = hopper("I") im.point(list(range(256))*256, 'L') def test_f_lut(self): """ Tests for floating point lut of 8bit gray image """ - im = lena('L') + im = hopper('L') lut = [0.5 * float(x) for x in range(256)] out = im.point(lut, 'F') int_lut = [x//2 for x in range(256)] self.assert_image_equal(out.convert('L'), im.point(int_lut, 'L')) - + if __name__ == '__main__': unittest.main() diff --git a/Tests/test_image_putdata.py b/Tests/test_image_putdata.py index acea0d62a..1535acf35 100644 --- a/Tests/test_image_putdata.py +++ b/Tests/test_image_putdata.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper import sys @@ -9,7 +9,7 @@ class TestImagePutData(PillowTestCase): def test_sanity(self): - im1 = lena() + im1 = hopper() data = list(im1.getdata()) @@ -47,7 +47,7 @@ class TestImagePutData(PillowTestCase): im.putdata(list(range(256))*256) def test_mode_i(self): - src = lena('L') + src = hopper('L') data = list(src.getdata()) im = Image.new('I', src.size, 0) im.putdata(data, 2, 256) @@ -56,7 +56,7 @@ class TestImagePutData(PillowTestCase): self.assertEqual(list(im.getdata()), target) def test_mode_F(self): - src = lena('L') + src = hopper('L') data = list(src.getdata()) im = Image.new('F', src.size, 0) im.putdata(data, 2.0, 256.0) @@ -64,7 +64,7 @@ class TestImagePutData(PillowTestCase): target = [2.0* float(elt) + 256.0 for elt in data] self.assertEqual(list(im.getdata()), target) - + if __name__ == '__main__': unittest.main() diff --git a/Tests/test_image_putpalette.py b/Tests/test_image_putpalette.py index a77c1e565..a1f00c361 100644 --- a/Tests/test_image_putpalette.py +++ b/Tests/test_image_putpalette.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import ImagePalette @@ -7,7 +7,7 @@ class TestImagePutPalette(PillowTestCase): def test_putpalette(self): def palette(mode): - im = lena(mode).copy() + im = hopper(mode).copy() im.putpalette(list(range(256))*3) p = im.getpalette() if p: @@ -23,7 +23,7 @@ class TestImagePutPalette(PillowTestCase): self.assertRaises(ValueError, lambda: palette("YCbCr")) def test_imagepalette(self): - im = lena("P") + im = hopper("P") im.putpalette(ImagePalette.negative()) im.putpalette(ImagePalette.random()) im.putpalette(ImagePalette.sepia()) diff --git a/Tests/test_image_putpixel.py b/Tests/test_image_putpixel.py index a7f5dc2bb..418e9703c 100644 --- a/Tests/test_image_putpixel.py +++ b/Tests/test_image_putpixel.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image @@ -9,7 +9,7 @@ class TestImagePutPixel(PillowTestCase): def test_sanity(self): - im1 = lena() + im1 = hopper() im2 = Image.new(im1.mode, im1.size, 0) for y in range(im1.size[1]): diff --git a/Tests/test_image_quantize.py b/Tests/test_image_quantize.py index 2cbdac225..e8183eb48 100644 --- a/Tests/test_image_quantize.py +++ b/Tests/test_image_quantize.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image @@ -6,17 +6,17 @@ from PIL import Image class TestImageQuantize(PillowTestCase): def test_sanity(self): - im = lena() + im = hopper() im = im.quantize() self.assert_image(im, "P", im.size) - im = lena() - im = im.quantize(palette=lena("P")) + im = hopper() + im = im.quantize(palette=hopper("P")) self.assert_image(im, "P", im.size) def test_octree_quantize(self): - im = lena() + im = hopper() im = im.quantize(100, Image.FASTOCTREE) self.assert_image(im, "P", im.size) @@ -24,7 +24,7 @@ class TestImageQuantize(PillowTestCase): assert len(im.getcolors()) == 100 def test_rgba_quantize(self): - im = lena('RGBA') + im = hopper('RGBA') im.quantize() self.assertRaises(Exception, lambda: im.quantize(method=0)) diff --git a/Tests/test_image_resize.py b/Tests/test_image_resize.py index 6c9932e45..603f598d8 100644 --- a/Tests/test_image_resize.py +++ b/Tests/test_image_resize.py @@ -1,11 +1,11 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper class TestImageResize(PillowTestCase): def test_resize(self): def resize(mode, size): - out = lena(mode).resize(size) + out = hopper(mode).resize(size) self.assertEqual(out.mode, mode) self.assertEqual(out.size, size) for mode in "1", "P", "L", "RGB", "I", "F": diff --git a/Tests/test_image_rotate.py b/Tests/test_image_rotate.py index 531fdd63f..38391adae 100644 --- a/Tests/test_image_rotate.py +++ b/Tests/test_image_rotate.py @@ -1,11 +1,11 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper class TestImageRotate(PillowTestCase): def test_rotate(self): def rotate(mode): - im = lena(mode) + im = hopper(mode) out = im.rotate(45) self.assertEqual(out.mode, mode) self.assertEqual(out.size, im.size) # default rotate clips output diff --git a/Tests/test_image_split.py b/Tests/test_image_split.py index 343f4bf8e..0e057523b 100644 --- a/Tests/test_image_split.py +++ b/Tests/test_image_split.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image @@ -7,7 +7,7 @@ class TestImageSplit(PillowTestCase): def test_split(self): def split(mode): - layers = lena(mode).split() + layers = hopper(mode).split() return [(i.mode, i.size[0], i.size[1]) for i in layers] self.assertEqual(split("1"), [('1', 128, 128)]) self.assertEqual(split("L"), [('L', 128, 128)]) @@ -30,16 +30,16 @@ class TestImageSplit(PillowTestCase): def test_split_merge(self): def split_merge(mode): - return Image.merge(mode, lena(mode).split()) - self.assert_image_equal(lena("1"), split_merge("1")) - self.assert_image_equal(lena("L"), split_merge("L")) - self.assert_image_equal(lena("I"), split_merge("I")) - self.assert_image_equal(lena("F"), split_merge("F")) - self.assert_image_equal(lena("P"), split_merge("P")) - self.assert_image_equal(lena("RGB"), split_merge("RGB")) - self.assert_image_equal(lena("RGBA"), split_merge("RGBA")) - self.assert_image_equal(lena("CMYK"), split_merge("CMYK")) - self.assert_image_equal(lena("YCbCr"), split_merge("YCbCr")) + return Image.merge(mode, hopper(mode).split()) + self.assert_image_equal(hopper("1"), split_merge("1")) + self.assert_image_equal(hopper("L"), split_merge("L")) + self.assert_image_equal(hopper("I"), split_merge("I")) + self.assert_image_equal(hopper("F"), split_merge("F")) + self.assert_image_equal(hopper("P"), split_merge("P")) + self.assert_image_equal(hopper("RGB"), split_merge("RGB")) + self.assert_image_equal(hopper("RGBA"), split_merge("RGBA")) + self.assert_image_equal(hopper("CMYK"), split_merge("CMYK")) + self.assert_image_equal(hopper("YCbCr"), split_merge("YCbCr")) def test_split_open(self): codecs = dir(Image.core) @@ -50,7 +50,7 @@ class TestImageSplit(PillowTestCase): file = self.tempfile("temp.pcx") def split_open(mode): - lena(mode).save(file) + hopper(mode).save(file) im = Image.open(file) return len(im.split()) self.assertEqual(split_open("1"), 1) diff --git a/Tests/test_image_thumbnail.py b/Tests/test_image_thumbnail.py index ee49be43e..d4c676bbd 100644 --- a/Tests/test_image_thumbnail.py +++ b/Tests/test_image_thumbnail.py @@ -1,38 +1,38 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper class TestImageThumbnail(PillowTestCase): def test_sanity(self): - im = lena() + im = hopper() im.thumbnail((100, 100)) self.assert_image(im, im.mode, (100, 100)) def test_aspect(self): - im = lena() + im = hopper() im.thumbnail((100, 100)) self.assert_image(im, im.mode, (100, 100)) - im = lena().resize((128, 256)) + im = hopper().resize((128, 256)) im.thumbnail((100, 100)) self.assert_image(im, im.mode, (50, 100)) - im = lena().resize((128, 256)) + im = hopper().resize((128, 256)) im.thumbnail((50, 100)) self.assert_image(im, im.mode, (50, 100)) - im = lena().resize((256, 128)) + im = hopper().resize((256, 128)) im.thumbnail((100, 100)) self.assert_image(im, im.mode, (100, 50)) - im = lena().resize((256, 128)) + im = hopper().resize((256, 128)) im.thumbnail((100, 50)) self.assert_image(im, im.mode, (100, 50)) - im = lena().resize((128, 128)) + im = hopper().resize((128, 128)) im.thumbnail((100, 100)) self.assert_image(im, im.mode, (100, 100)) diff --git a/Tests/test_image_tobitmap.py b/Tests/test_image_tobitmap.py index 56b5ef001..e26a225c2 100644 --- a/Tests/test_image_tobitmap.py +++ b/Tests/test_image_tobitmap.py @@ -1,14 +1,14 @@ -from helper import unittest, PillowTestCase, lena, fromstring +from helper import unittest, PillowTestCase, hopper, fromstring class TestImageToBitmap(PillowTestCase): def test_sanity(self): - self.assertRaises(ValueError, lambda: lena().tobitmap()) - lena().convert("1").tobitmap() + self.assertRaises(ValueError, lambda: hopper().tobitmap()) + hopper().convert("1").tobitmap() - im1 = lena().convert("1") + im1 = hopper().convert("1") bitmap = im1.tobitmap() diff --git a/Tests/test_image_tobytes.py b/Tests/test_image_tobytes.py index 6dbf7d6f2..31a7e1722 100644 --- a/Tests/test_image_tobytes.py +++ b/Tests/test_image_tobytes.py @@ -1,10 +1,10 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper class TestImageToBytes(PillowTestCase): def test_sanity(self): - data = lena().tobytes() + data = hopper().tobytes() self.assertTrue(isinstance(data, bytes)) if __name__ == '__main__': diff --git a/Tests/test_image_transform.py b/Tests/test_image_transform.py index 42a3d78f3..c4111d0b6 100644 --- a/Tests/test_image_transform.py +++ b/Tests/test_image_transform.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image @@ -22,7 +22,7 @@ class TestImageTransform(PillowTestCase): im.transform((100, 100), transform) def test_extent(self): - im = lena('RGB') + im = hopper('RGB') (w, h) = im.size transformed = im.transform(im.size, Image.EXTENT, (0, 0, @@ -32,11 +32,11 @@ class TestImageTransform(PillowTestCase): scaled = im.resize((w*2, h*2), Image.BILINEAR).crop((0, 0, w, h)) # undone -- precision? - self.assert_image_similar(transformed, scaled, 10) + self.assert_image_similar(transformed, scaled, 23) def test_quad(self): # one simple quad transform, equivalent to scale & crop upper left quad - im = lena('RGB') + im = hopper('RGB') (w, h) = im.size transformed = im.transform(im.size, Image.QUAD, (0, 0, 0, h//2, @@ -49,8 +49,8 @@ class TestImageTransform(PillowTestCase): self.assert_image_equal(transformed, scaled) def test_mesh(self): - # this should be a checkerboard of halfsized lenas in ul, lr - im = lena('RGBA') + # this should be a checkerboard of halfsized hoppers in ul, lr + im = hopper('RGBA') (w, h) = im.size transformed = im.transform(im.size, Image.MESH, [((0, 0, w//2, h//2), # box diff --git a/Tests/test_image_transpose.py b/Tests/test_image_transpose.py index f13e54ee7..3e4257bc0 100644 --- a/Tests/test_image_transpose.py +++ b/Tests/test_image_transpose.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image @@ -13,7 +13,7 @@ class TestImageTranspose(PillowTestCase): def test_sanity(self): - im = lena() + im = hopper() im.transpose(FLIP_LEFT_RIGHT) im.transpose(FLIP_TOP_BOTTOM) @@ -24,7 +24,7 @@ class TestImageTranspose(PillowTestCase): def test_roundtrip(self): - im = lena() + im = hopper() def transpose(first, second): return im.transpose(first).transpose(second) diff --git a/Tests/test_imagechops.py b/Tests/test_imagechops.py index 552314fd1..a3b7fa606 100644 --- a/Tests/test_imagechops.py +++ b/Tests/test_imagechops.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image from PIL import ImageChops @@ -8,7 +8,7 @@ class TestImageChops(PillowTestCase): def test_sanity(self): - im = lena("L") + im = hopper("L") ImageChops.constant(im, 128) ImageChops.duplicate(im) diff --git a/Tests/test_imagedraw.py b/Tests/test_imagedraw.py index b632da73b..76e49deb4 100644 --- a/Tests/test_imagedraw.py +++ b/Tests/test_imagedraw.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image from PIL import ImageColor @@ -34,7 +34,7 @@ POINTS2 = [10, 10, 20, 40, 30, 30] class TestImageDraw(PillowTestCase): def test_sanity(self): - im = lena("RGB").copy() + im = hopper("RGB").copy() draw = ImageDraw.ImageDraw(im) draw = ImageDraw.Draw(im) @@ -45,7 +45,7 @@ class TestImageDraw(PillowTestCase): draw.rectangle(list(range(4))) def test_deprecated(self): - im = lena().copy() + im = hopper().copy() draw = ImageDraw.Draw(im) diff --git a/Tests/test_imagefile.py b/Tests/test_imagefile.py index 78fb3427f..3556661ae 100644 --- a/Tests/test_imagefile.py +++ b/Tests/test_imagefile.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena, fromstring, tostring +from helper import unittest, PillowTestCase, hopper, fromstring, tostring from io import BytesIO @@ -20,7 +20,7 @@ class TestImageFile(PillowTestCase): def roundtrip(format): - im = lena("L").resize((1000, 1000)) + im = hopper("L").resize((1000, 1000)) if format in ("MSP", "XBM"): im = im.convert("1") @@ -73,7 +73,7 @@ class TestImageFile(PillowTestCase): def test_safeblock(self): - im1 = lena() + im1 = hopper() if "zip_encoder" not in codecs: self.skipTest("PNG (zlib) encoder not available") diff --git a/Tests/test_imagefileio.py b/Tests/test_imagefileio.py index 32ee0bc5e..f18474403 100644 --- a/Tests/test_imagefileio.py +++ b/Tests/test_imagefileio.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena, tostring +from helper import unittest, PillowTestCase, hopper, tostring from PIL import Image from PIL import ImageFileIO @@ -19,7 +19,7 @@ class TestImageFileIo(PillowTestCase): def close(self): pass - im1 = lena() + im1 = hopper() io = ImageFileIO.ImageFileIO(DumbFile(tostring(im1, "PPM"))) diff --git a/Tests/test_imageops.py b/Tests/test_imageops.py index a4a94ca4d..0ffb14bfe 100644 --- a/Tests/test_imageops.py +++ b/Tests/test_imageops.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import ImageOps @@ -14,65 +14,65 @@ class TestImageOps(PillowTestCase): def test_sanity(self): - ImageOps.autocontrast(lena("L")) - ImageOps.autocontrast(lena("RGB")) + ImageOps.autocontrast(hopper("L")) + ImageOps.autocontrast(hopper("RGB")) - ImageOps.autocontrast(lena("L"), cutoff=10) - ImageOps.autocontrast(lena("L"), ignore=[0, 255]) + ImageOps.autocontrast(hopper("L"), cutoff=10) + ImageOps.autocontrast(hopper("L"), ignore=[0, 255]) - ImageOps.colorize(lena("L"), (0, 0, 0), (255, 255, 255)) - ImageOps.colorize(lena("L"), "black", "white") + ImageOps.colorize(hopper("L"), (0, 0, 0), (255, 255, 255)) + ImageOps.colorize(hopper("L"), "black", "white") - ImageOps.crop(lena("L"), 1) - ImageOps.crop(lena("RGB"), 1) + ImageOps.crop(hopper("L"), 1) + ImageOps.crop(hopper("RGB"), 1) - ImageOps.deform(lena("L"), self.deformer) - ImageOps.deform(lena("RGB"), self.deformer) + ImageOps.deform(hopper("L"), self.deformer) + ImageOps.deform(hopper("RGB"), self.deformer) - ImageOps.equalize(lena("L")) - ImageOps.equalize(lena("RGB")) + ImageOps.equalize(hopper("L")) + ImageOps.equalize(hopper("RGB")) - ImageOps.expand(lena("L"), 1) - ImageOps.expand(lena("RGB"), 1) - ImageOps.expand(lena("L"), 2, "blue") - ImageOps.expand(lena("RGB"), 2, "blue") + ImageOps.expand(hopper("L"), 1) + ImageOps.expand(hopper("RGB"), 1) + ImageOps.expand(hopper("L"), 2, "blue") + ImageOps.expand(hopper("RGB"), 2, "blue") - ImageOps.fit(lena("L"), (128, 128)) - ImageOps.fit(lena("RGB"), (128, 128)) + ImageOps.fit(hopper("L"), (128, 128)) + ImageOps.fit(hopper("RGB"), (128, 128)) - ImageOps.flip(lena("L")) - ImageOps.flip(lena("RGB")) + ImageOps.flip(hopper("L")) + ImageOps.flip(hopper("RGB")) - ImageOps.grayscale(lena("L")) - ImageOps.grayscale(lena("RGB")) + ImageOps.grayscale(hopper("L")) + ImageOps.grayscale(hopper("RGB")) - ImageOps.invert(lena("L")) - ImageOps.invert(lena("RGB")) + ImageOps.invert(hopper("L")) + ImageOps.invert(hopper("RGB")) - ImageOps.mirror(lena("L")) - ImageOps.mirror(lena("RGB")) + ImageOps.mirror(hopper("L")) + ImageOps.mirror(hopper("RGB")) - ImageOps.posterize(lena("L"), 4) - ImageOps.posterize(lena("RGB"), 4) + ImageOps.posterize(hopper("L"), 4) + ImageOps.posterize(hopper("RGB"), 4) - ImageOps.solarize(lena("L")) - ImageOps.solarize(lena("RGB")) + ImageOps.solarize(hopper("L")) + ImageOps.solarize(hopper("RGB")) def test_1pxfit(self): # Division by zero in equalize if image is 1 pixel high - newimg = ImageOps.fit(lena("RGB").resize((1, 1)), (35, 35)) + newimg = ImageOps.fit(hopper("RGB").resize((1, 1)), (35, 35)) self.assertEqual(newimg.size, (35, 35)) - newimg = ImageOps.fit(lena("RGB").resize((1, 100)), (35, 35)) + newimg = ImageOps.fit(hopper("RGB").resize((1, 100)), (35, 35)) self.assertEqual(newimg.size, (35, 35)) - newimg = ImageOps.fit(lena("RGB").resize((100, 1)), (35, 35)) + newimg = ImageOps.fit(hopper("RGB").resize((100, 1)), (35, 35)) self.assertEqual(newimg.size, (35, 35)) def test_pil163(self): # Division by zero in equalize if < 255 pixels in image (@PIL163) - i = lena("RGB").resize((15, 16)) + i = hopper("RGB").resize((15, 16)) ImageOps.equalize(i.convert("L")) ImageOps.equalize(i.convert("P")) diff --git a/Tests/test_imageops_usm.py b/Tests/test_imageops_usm.py index be7a669da..ba65f211b 100644 --- a/Tests/test_imageops_usm.py +++ b/Tests/test_imageops_usm.py @@ -4,7 +4,7 @@ from PIL import Image from PIL import ImageOps from PIL import ImageFilter -im = Image.open("Tests/images/lena.ppm") +im = Image.open("Tests/images/hopper.ppm") class TestImageOpsUsm(PillowTestCase): diff --git a/Tests/test_imageqt.py b/Tests/test_imageqt.py index fd50bf320..cd26e0038 100644 --- a/Tests/test_imageqt.py +++ b/Tests/test_imageqt.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper try: from PIL import ImageQt @@ -44,7 +44,7 @@ class TestImageQt(PillowTestCase): def test_image(self): for mode in ('1', 'RGB', 'RGBA', 'L', 'P'): - ImageQt.ImageQt(lena(mode)) + ImageQt.ImageQt(hopper(mode)) if __name__ == '__main__': diff --git a/Tests/test_imagesequence.py b/Tests/test_imagesequence.py index 068290451..62a83cda6 100644 --- a/Tests/test_imagesequence.py +++ b/Tests/test_imagesequence.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image, ImageSequence, TiffImagePlugin @@ -9,7 +9,7 @@ class TestImageSequence(PillowTestCase): file = self.tempfile("temp.im") - im = lena("RGB") + im = hopper("RGB") im.save(file) seq = ImageSequence.Iterator(im) @@ -31,14 +31,14 @@ class TestImageSequence(PillowTestCase): self.assertEqual(index, im.tell()) frame.convert('RGB') Image.DEBUG=False - + def test_tiff(self): #self._test_multipage_tiff(True) self._test_multipage_tiff(False) def test_libtiff(self): codecs = dir(Image.core) - + if "libtiff_encoder" not in codecs or "libtiff_decoder" not in codecs: self.skipTest("tiff support not available") @@ -46,7 +46,7 @@ class TestImageSequence(PillowTestCase): #self._test_multipage_tiff(True) self._test_multipage_tiff(False) TiffImagePlugin.READ_LIBTIFF = False - + if __name__ == '__main__': unittest.main() diff --git a/Tests/test_imagestat.py b/Tests/test_imagestat.py index 4d30ff023..4d5e42b3f 100644 --- a/Tests/test_imagestat.py +++ b/Tests/test_imagestat.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image from PIL import ImageStat @@ -8,7 +8,7 @@ class TestImageStat(PillowTestCase): def test_sanity(self): - im = lena() + im = hopper() st = ImageStat.Stat(im) st = ImageStat.Stat(im.histogram()) @@ -28,18 +28,18 @@ class TestImageStat(PillowTestCase): self.assertRaises(TypeError, lambda: ImageStat.Stat(1)) - def test_lena(self): + def test_hopper(self): - im = lena() + im = hopper() st = ImageStat.Stat(im) # verify a few values - self.assertEqual(st.extrema[0], (61, 255)) - self.assertEqual(st.median[0], 197) - self.assertEqual(st.sum[0], 2954416) - self.assertEqual(st.sum[1], 2027250) - self.assertEqual(st.sum[2], 1727331) + self.assertEqual(st.extrema[0], (0, 255)) + self.assertEqual(st.median[0], 72) + self.assertEqual(st.sum[0], 1470218) + self.assertEqual(st.sum[1], 1311896) + self.assertEqual(st.sum[2], 1563008) def test_constant(self): diff --git a/Tests/test_locale.py b/Tests/test_locale.py index 9ef136bf9..e4fab1497 100644 --- a/Tests/test_locale.py +++ b/Tests/test_locale.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image @@ -19,7 +19,7 @@ import locale # one of string.whitespace is not freely convertable into ascii. -path = "Tests/images/lena.jpg" +path = "Tests/images/hopper.jpg" class TestLocale(PillowTestCase): diff --git a/Tests/test_mode_i16.py b/Tests/test_mode_i16.py index 0cd5dba0f..0bd2b9a86 100644 --- a/Tests/test_mode_i16.py +++ b/Tests/test_mode_i16.py @@ -1,11 +1,11 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image class TestModeI16(PillowTestCase): - original = lena().resize((32,32)).convert('I') + original = hopper().resize((32,32)).convert('I') def verify(self, im1): im2 = self.original.copy() diff --git a/Tests/test_numpy.py b/Tests/test_numpy.py index 07c3e0c21..b00b8b36b 100644 --- a/Tests/test_numpy.py +++ b/Tests/test_numpy.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image @@ -90,7 +90,7 @@ class TestNumpy(PillowTestCase): def test_to_array(self): def _to_array(mode, dtype): - img = lena(mode) + img = hopper(mode) np_img = numpy.array(img) self._test_img_equals_nparray(img, np_img) self.assertEqual(np_img.dtype, numpy.dtype(dtype)) @@ -117,7 +117,7 @@ class TestNumpy(PillowTestCase): data = list(range(256))*3 lut = numpy.array(data, dtype='uint8') - im = lena() + im = hopper() im.point(lut) diff --git a/Tests/test_pickle.py b/Tests/test_pickle.py index eae5eb671..59dfd5948 100644 --- a/Tests/test_pickle.py +++ b/Tests/test_pickle.py @@ -6,7 +6,8 @@ from PIL import Image class TestPickle(PillowTestCase): def helper_pickle_file(self, pickle, protocol=0): - im = Image.open('Tests/images/lena.jpg') + # Arrange + im = Image.open('Tests/images/hopper.jpg') filename = self.tempfile('temp.pkl') # Act @@ -19,7 +20,7 @@ class TestPickle(PillowTestCase): self.assertEqual(im, loaded_im) def helper_pickle_string( - self, pickle, protocol=0, file='Tests/images/lena.jpg'): + self, pickle, protocol=0, file='Tests/images/hopper.jpg'): im = Image.open(file) # Act diff --git a/Tests/threaded_save.py b/Tests/threaded_save.py index 12fcff2cf..14ef42f17 100644 --- a/Tests/threaded_save.py +++ b/Tests/threaded_save.py @@ -9,7 +9,7 @@ try: except: format = "PNG" -im = Image.open("Tests/images/lena.ppm") +im = Image.open("Tests/images/hopper.ppm") im.load() queue = queue.Queue()