Merge pull request #708 from hugovk/single_image_dir

Put images in a single directory
This commit is contained in:
Alex Clark ☺ 2014-06-23 12:26:27 -04:00
commit 70a8337a4a
44 changed files with 39 additions and 39 deletions

View File

@ -396,7 +396,7 @@ w7IkEbzhVQAAAABJRU5ErkJggg==
if __name__ == "__main__": if __name__ == "__main__":
# create font data chunk for embedding # create font data chunk for embedding
import base64, os, sys import base64, os, sys
font = "../Images/courB08" font = "../Tests/images/courB08"
print(" f._load_pilfont_data(") print(" f._load_pilfont_data(")
print(" # %s" % os.path.basename(font)) print(" # %s" % os.path.basename(font))
print(" BytesIO(base64.decodestring(b'''") print(" BytesIO(base64.decodestring(b'''")

View File

@ -233,7 +233,7 @@ def lena(mode="RGB", cache={}):
# im = cache.get(mode) # im = cache.get(mode)
if im is None: if im is None:
if mode == "RGB": if mode == "RGB":
im = Image.open("Images/lena.ppm") im = Image.open("Tests/images/lena.ppm")
elif mode == "F": elif mode == "F":
im = lena("L").convert(mode) im = lena("L").convert(mode)
elif mode[:4] == "I;16": elif mode[:4] == "I;16":

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 29 KiB

View File

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 37 KiB

View File

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

Before

Width:  |  Height:  |  Size: 100 KiB

After

Width:  |  Height:  |  Size: 100 KiB

View File

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

View File

Before

Width:  |  Height:  |  Size: 7.9 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

View File

@ -3,7 +3,7 @@ from helper import unittest, PillowTestCase, tearDownModule
from PIL import Image from PIL import Image
# sample ppm stream # sample ppm stream
file = "Images/lena.fli" file = "Tests/images/lena.fli"
data = open(file, "rb").read() data = open(file, "rb").read()

View File

@ -5,7 +5,7 @@ from PIL import Image
codecs = dir(Image.core) codecs = dir(Image.core)
# sample gif stream # sample gif stream
file = "Images/lena.gif" file = "Tests/images/lena.gif"
with open(file, "rb") as f: with open(file, "rb") as f:
data = f.read() data = f.read()
@ -45,7 +45,7 @@ class TestFileGif(PillowTestCase):
def test_roundtrip2(self): def test_roundtrip2(self):
# see https://github.com/python-pillow/Pillow/issues/403 # see https://github.com/python-pillow/Pillow/issues/403
out = self.tempfile('temp.gif') out = self.tempfile('temp.gif')
im = Image.open('Images/lena.gif') im = Image.open('Tests/images/lena.gif')
im2 = im.copy() im2 = im.copy()
im2.save(out) im2.save(out)
reread = Image.open(out) reread = Image.open(out)
@ -55,7 +55,7 @@ class TestFileGif(PillowTestCase):
def test_palette_handling(self): def test_palette_handling(self):
# see https://github.com/python-pillow/Pillow/issues/513 # see https://github.com/python-pillow/Pillow/issues/513
im = Image.open('Images/lena.gif') im = Image.open('Tests/images/lena.gif')
im = im.convert('RGB') im = im.convert('RGB')
im = im.resize((100, 100), Image.ANTIALIAS) im = im.resize((100, 100), Image.ANTIALIAS)

View File

@ -3,7 +3,7 @@ from helper import unittest, PillowTestCase, tearDownModule
from PIL import Image from PIL import Image
# sample icon file # sample icon file
file = "Images/pillow.icns" file = "Tests/images/pillow.icns"
data = open(file, "rb").read() data = open(file, "rb").read()
enable_jpeg2k = hasattr(Image.core, 'jp2klib_version') enable_jpeg2k = hasattr(Image.core, 'jp2klib_version')

View File

@ -3,7 +3,7 @@ from helper import unittest, PillowTestCase, tearDownModule
from PIL import Image from PIL import Image
# sample ppm stream # sample ppm stream
file = "Images/lena.ico" file = "Tests/images/lena.ico"
data = open(file, "rb").read() data = open(file, "rb").read()

View File

@ -8,7 +8,7 @@ from PIL import ImageFile
codecs = dir(Image.core) codecs = dir(Image.core)
test_file = "Images/lena.jpg" test_file = "Tests/images/lena.jpg"
class TestFileJpeg(PillowTestCase): class TestFileJpeg(PillowTestCase):
@ -215,7 +215,7 @@ class TestFileJpeg(PillowTestCase):
self.assertEqual(info[305], 'Adobe Photoshop CS Macintosh') self.assertEqual(info[305], 'Adobe Photoshop CS Macintosh')
def test_quality_keep(self): def test_quality_keep(self):
im = Image.open("Images/lena.jpg") im = Image.open("Tests/images/lena.jpg")
f = self.tempfile('temp.jpg') f = self.tempfile('temp.jpg')
im.save(f, quality='keep') im.save(f, quality='keep')

View File

@ -10,7 +10,7 @@ codecs = dir(Image.core)
# sample png stream # sample png stream
file = "Images/lena.png" file = "Tests/images/lena.png"
data = open(file, "rb").read() data = open(file, "rb").read()
# stuff to create inline PNG images # stuff to create inline PNG images
@ -204,10 +204,10 @@ class TestFilePng(PillowTestCase):
def test_load_verify(self): def test_load_verify(self):
# Check open/load/verify exception (@PIL150) # Check open/load/verify exception (@PIL150)
im = Image.open("Images/lena.png") im = Image.open("Tests/images/lena.png")
im.verify() im.verify()
im = Image.open("Images/lena.png") im = Image.open("Tests/images/lena.png")
im.load() im.load()
self.assertRaises(RuntimeError, lambda: im.verify()) self.assertRaises(RuntimeError, lambda: im.verify())

View File

@ -3,7 +3,7 @@ from helper import unittest, PillowTestCase, tearDownModule
from PIL import Image from PIL import Image
# sample ppm stream # sample ppm stream
file = "Images/lena.ppm" file = "Tests/images/lena.ppm"
data = open(file, "rb").read() data = open(file, "rb").read()

View File

@ -3,7 +3,7 @@ from helper import unittest, PillowTestCase, tearDownModule
from PIL import Image from PIL import Image
# sample ppm stream # sample ppm stream
file = "Images/lena.psd" file = "Tests/images/lena.psd"
data = open(file, "rb").read() data = open(file, "rb").read()

View File

@ -5,7 +5,7 @@ from PIL import Image, TarIO
codecs = dir(Image.core) codecs = dir(Image.core)
# sample ppm stream # sample ppm stream
tarfile = "Images/lena.tar" tarfile = "Tests/images/lena.tar"
class TestFileTar(PillowTestCase): class TestFileTar(PillowTestCase):

View File

@ -23,7 +23,7 @@ class TestFileWebp(PillowTestCase):
def test_read_rgb(self): def test_read_rgb(self):
file_path = "Images/lena.webp" file_path = "Tests/images/lena.webp"
image = Image.open(file_path) image = Image.open(file_path)
self.assertEqual(image.mode, "RGB") self.assertEqual(image.mode, "RGB")
@ -33,7 +33,7 @@ class TestFileWebp(PillowTestCase):
image.getdata() image.getdata()
# generated with: # generated with:
# dwebp -ppm ../../Images/lena.webp -o lena_webp_bits.ppm # dwebp -ppm ../../Tests/images/lena.webp -o lena_webp_bits.ppm
target = Image.open('Tests/images/lena_webp_bits.ppm') target = Image.open('Tests/images/lena_webp_bits.ppm')
self.assert_image_similar(image, target, 20.0) self.assert_image_similar(image, target, 20.0)

View File

@ -22,7 +22,7 @@ class TestFileWebpAlpha(PillowTestCase):
def test_read_rgba(self): def test_read_rgba(self):
# Generated with `cwebp transparent.png -o transparent.webp` # Generated with `cwebp transparent.png -o transparent.webp`
file_path = "Images/transparent.webp" file_path = "Tests/images/transparent.webp"
image = Image.open(file_path) image = Image.open(file_path)
self.assertEqual(image.mode, "RGBA") self.assertEqual(image.mode, "RGBA")
@ -33,7 +33,7 @@ class TestFileWebpAlpha(PillowTestCase):
image.tobytes() image.tobytes()
target = Image.open('Images/transparent.png') target = Image.open('Tests/images/transparent.png')
self.assert_image_similar(image, target, 20.0) self.assert_image_similar(image, target, 20.0)
def test_write_lossless_rgb(self): def test_write_lossless_rgb(self):

View File

@ -15,7 +15,7 @@ class TestFileWebpMetadata(PillowTestCase):
def test_read_exif_metadata(self): def test_read_exif_metadata(self):
file_path = "Images/flower.webp" file_path = "Tests/images/flower.webp"
image = Image.open(file_path) image = Image.open(file_path)
self.assertEqual(image.format, "WEBP") self.assertEqual(image.format, "WEBP")
@ -54,7 +54,7 @@ class TestFileWebpMetadata(PillowTestCase):
def test_read_icc_profile(self): def test_read_icc_profile(self):
file_path = "Images/flower2.webp" file_path = "Tests/images/flower2.webp"
image = Image.open(file_path) image = Image.open(file_path)
self.assertEqual(image.format, "WEBP") self.assertEqual(image.format, "WEBP")

View File

@ -3,7 +3,7 @@ from helper import unittest, PillowTestCase, tearDownModule
from PIL import Image from PIL import Image
# sample ppm stream # sample ppm stream
file = "Images/lena.xpm" file = "Tests/images/lena.xpm"
data = open(file, "rb").read() data = open(file, "rb").read()

View File

@ -2,7 +2,7 @@ from helper import unittest, PillowTestCase, tearDownModule
from PIL import FontFile, BdfFontFile from PIL import FontFile, BdfFontFile
filename = "Images/courB08.bdf" filename = "Tests/images/courB08.bdf"
class TestFontBdf(PillowTestCase): class TestFontBdf(PillowTestCase):

View File

@ -36,7 +36,7 @@ class TestImageConvert(PillowTestCase):
self.assertEqual(orig, converted) self.assertEqual(orig, converted)
def test_8bit(self): def test_8bit(self):
im = Image.open('Images/lena.jpg') im = Image.open('Tests/images/lena.jpg')
self._test_float_conversion(im.convert('L')) self._test_float_conversion(im.convert('L'))
def test_16bit(self): def test_16bit(self):

View File

@ -3,7 +3,7 @@ from helper import unittest, PillowTestCase, tearDownModule, fromstring, tostrin
from PIL import Image from PIL import Image
codecs = dir(Image.core) codecs = dir(Image.core)
filename = "Images/lena.jpg" filename = "Tests/images/lena.jpg"
data = tostring(Image.open(filename).resize((512, 512)), "JPEG") data = tostring(Image.open(filename).resize((512, 512)), "JPEG")

View File

@ -16,14 +16,14 @@ class TestImageLoad(PillowTestCase):
self.assertEqual(pix[0, 0], (223, 162, 133)) self.assertEqual(pix[0, 0], (223, 162, 133))
def test_close(self): def test_close(self):
im = Image.open("Images/lena.gif") im = Image.open("Tests/images/lena.gif")
im.close() im.close()
self.assertRaises(ValueError, lambda: im.load()) self.assertRaises(ValueError, lambda: im.load())
self.assertRaises(ValueError, lambda: im.getpixel((0, 0))) self.assertRaises(ValueError, lambda: im.getpixel((0, 0)))
def test_contextmanager(self): def test_contextmanager(self):
fn = None fn = None
with Image.open("Images/lena.gif") as im: with Image.open("Tests/images/lena.gif") as im:
fn = im.fp.fileno() fn = im.fp.fileno()
os.fstat(fn) os.fstat(fn)

View File

@ -4,7 +4,7 @@ from PIL import Image
from PIL import ImageOps from PIL import ImageOps
from PIL import ImageFilter from PIL import ImageFilter
im = Image.open("Images/lena.ppm") im = Image.open("Tests/images/lena.ppm")
class TestImageOpsUsm(PillowTestCase): class TestImageOpsUsm(PillowTestCase):

View File

@ -19,7 +19,7 @@ import locale
# one of string.whitespace is not freely convertable into ascii. # one of string.whitespace is not freely convertable into ascii.
path = "Images/lena.jpg" path = "Tests/images/lena.jpg"
class TestLocale(PillowTestCase): class TestLocale(PillowTestCase):

View File

@ -6,7 +6,7 @@ from PIL import Image
class TestPickle(PillowTestCase): class TestPickle(PillowTestCase):
def helper_pickle_file(self, pickle, protocol=0): def helper_pickle_file(self, pickle, protocol=0):
im = Image.open('Images/lena.jpg') im = Image.open('Tests/images/lena.jpg')
filename = self.tempfile('temp.pkl') filename = self.tempfile('temp.pkl')
# Act # Act
@ -19,7 +19,7 @@ class TestPickle(PillowTestCase):
self.assertEqual(im, loaded_im) self.assertEqual(im, loaded_im)
def helper_pickle_string( def helper_pickle_string(
self, pickle, protocol=0, file='Images/lena.jpg'): self, pickle, protocol=0, file='Tests/images/lena.jpg'):
im = Image.open(file) im = Image.open(file)
# Act # Act

View File

@ -215,7 +215,7 @@ def lena(mode="RGB", cache={}):
im = cache.get(mode) im = cache.get(mode)
if im is None: if im is None:
if mode == "RGB": if mode == "RGB":
im = Image.open("Images/lena.ppm") im = Image.open("Tests/images/lena.ppm")
elif mode == "F": elif mode == "F":
im = lena("L").convert(mode) im = lena("L").convert(mode)
elif mode[:4] == "I;16": elif mode[:4] == "I;16":

View File

@ -9,7 +9,7 @@ try:
except: except:
format = "PNG" format = "PNG"
im = Image.open("Images/lena.ppm") im = Image.open("Tests/images/lena.ppm")
im.load() im.load()
queue = queue.Queue() queue = queue.Queue()

View File

@ -49,13 +49,13 @@ def testimage():
Or open existing files: Or open existing files:
>>> im = Image.open(os.path.join(ROOT, "Images/lena.gif")) >>> im = Image.open(os.path.join(ROOT, "Tests/images/lena.gif"))
>>> _info(im) >>> _info(im)
('GIF', 'P', (128, 128)) ('GIF', 'P', (128, 128))
>>> _info(Image.open(os.path.join(ROOT, "Images/lena.ppm"))) >>> _info(Image.open(os.path.join(ROOT, "Tests/images/lena.ppm")))
('PPM', 'RGB', (128, 128)) ('PPM', 'RGB', (128, 128))
>>> try: >>> try:
... _info(Image.open(os.path.join(ROOT, "Images/lena.jpg"))) ... _info(Image.open(os.path.join(ROOT, "Tests/images/lena.jpg")))
... except IOError as v: ... except IOError as v:
... print(v) ... print(v)
('JPEG', 'RGB', (128, 128)) ('JPEG', 'RGB', (128, 128))
@ -63,7 +63,7 @@ def testimage():
PIL doesn't actually load the image data until it's needed, PIL doesn't actually load the image data until it's needed,
or you call the "load" method: or you call the "load" method:
>>> im = Image.open(os.path.join(ROOT, "Images/lena.ppm")) >>> im = Image.open(os.path.join(ROOT, "Tests/images/lena.ppm"))
>>> print(im.im) # internal image attribute >>> print(im.im) # internal image attribute
None None
>>> a = im.load() >>> a = im.load()
@ -73,7 +73,7 @@ def testimage():
You can apply many different operations on images. Most You can apply many different operations on images. Most
operations return a new image: operations return a new image:
>>> im = Image.open(os.path.join(ROOT, "Images/lena.ppm")) >>> im = Image.open(os.path.join(ROOT, "Tests/images/lena.ppm"))
>>> _info(im.convert("L")) >>> _info(im.convert("L"))
(None, 'L', (128, 128)) (None, 'L', (128, 128))
>>> _info(im.copy()) >>> _info(im.copy())