mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-03-03 11:35:52 +03:00
Add hopper() to eventually replace lena()
This commit is contained in:
parent
c3d3789da7
commit
5dd4d6d941
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user