mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-16 11:12:29 +03:00
Merge 995fe2b041
into fc7816f872
This commit is contained in:
commit
2a0878c9b4
|
@ -2,10 +2,15 @@ from tester import *
|
||||||
|
|
||||||
from PIL import Image, TarIO
|
from PIL import Image, TarIO
|
||||||
|
|
||||||
|
codecs = dir(Image.core)
|
||||||
|
if "zip_decoder" not in codecs and "jpeg_decoder" not in codecs:
|
||||||
|
skip("neither jpeg nor zip support not available")
|
||||||
|
|
||||||
# sample ppm stream
|
# sample ppm stream
|
||||||
tarfile = "Images/lena.tar"
|
tarfile = "Images/lena.tar"
|
||||||
|
|
||||||
def test_sanity():
|
def test_sanity():
|
||||||
|
if "zip_decoder" in codecs:
|
||||||
tar = TarIO.TarIO(tarfile, 'lena.png')
|
tar = TarIO.TarIO(tarfile, 'lena.png')
|
||||||
im = Image.open(tar)
|
im = Image.open(tar)
|
||||||
im.load()
|
im.load()
|
||||||
|
@ -13,6 +18,7 @@ def test_sanity():
|
||||||
assert_equal(im.size, (128, 128))
|
assert_equal(im.size, (128, 128))
|
||||||
assert_equal(im.format, "PNG")
|
assert_equal(im.format, "PNG")
|
||||||
|
|
||||||
|
if "jpeg_decoder" in codecs:
|
||||||
tar = TarIO.TarIO(tarfile, 'lena.jpg')
|
tar = TarIO.TarIO(tarfile, 'lena.jpg')
|
||||||
im = Image.open(tar)
|
im = Image.open(tar)
|
||||||
im.load()
|
im.load()
|
||||||
|
|
|
@ -4,6 +4,11 @@ from PIL import Image
|
||||||
|
|
||||||
import random
|
import random
|
||||||
|
|
||||||
|
codecs = dir(Image.core)
|
||||||
|
|
||||||
|
if "group4_encoder" not in codecs or "group4_decoder" not in codecs:
|
||||||
|
skip("tiff support not available")
|
||||||
|
|
||||||
def test_sanity():
|
def test_sanity():
|
||||||
|
|
||||||
file = tempfile("temp.tif")
|
file = tempfile("temp.tif")
|
||||||
|
|
|
@ -3,6 +3,11 @@ from tester import *
|
||||||
from PIL import Image, FontFile, PcfFontFile
|
from PIL import Image, FontFile, PcfFontFile
|
||||||
from PIL import ImageFont, ImageDraw
|
from PIL import ImageFont, ImageDraw
|
||||||
|
|
||||||
|
codecs = dir(Image.core)
|
||||||
|
|
||||||
|
if "zip_encoder" not in codecs or "zip_decoder" not in codecs:
|
||||||
|
skip("zlib support not available")
|
||||||
|
|
||||||
fontname = "Tests/fonts/helvO18.pcf"
|
fontname = "Tests/fonts/helvO18.pcf"
|
||||||
tempname = tempfile("temp.pil", "temp.pbm")
|
tempname = tempfile("temp.pil", "temp.pbm")
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,11 @@ from tester import *
|
||||||
|
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
|
codecs = dir(Image.core)
|
||||||
|
|
||||||
|
if "jpeg_encoder" not in codecs or "jpeg_decoder" not in codecs:
|
||||||
|
skip("jpeg support not available")
|
||||||
|
|
||||||
filename = "Images/lena.jpg"
|
filename = "Images/lena.jpg"
|
||||||
|
|
||||||
data = tostring(Image.open(filename).resize((512, 512)), "JPEG")
|
data = tostring(Image.open(filename).resize((512, 512)), "JPEG")
|
||||||
|
|
|
@ -30,7 +30,13 @@ def test_split_merge():
|
||||||
assert_image_equal(lena("YCbCr"), split_merge("YCbCr"))
|
assert_image_equal(lena("YCbCr"), split_merge("YCbCr"))
|
||||||
|
|
||||||
def test_split_open():
|
def test_split_open():
|
||||||
|
codecs = dir(Image.core)
|
||||||
|
|
||||||
|
if 'zip_encoder' in codecs:
|
||||||
file = tempfile("temp.png")
|
file = tempfile("temp.png")
|
||||||
|
else:
|
||||||
|
file = tempfile("temp.pcx")
|
||||||
|
|
||||||
def split_open(mode):
|
def split_open(mode):
|
||||||
lena(mode).save(file)
|
lena(mode).save(file)
|
||||||
im = Image.open(file)
|
im = Image.open(file)
|
||||||
|
@ -39,4 +45,5 @@ def test_split_open():
|
||||||
assert_equal(split_open("L"), 1)
|
assert_equal(split_open("L"), 1)
|
||||||
assert_equal(split_open("P"), 1)
|
assert_equal(split_open("P"), 1)
|
||||||
assert_equal(split_open("RGB"), 3)
|
assert_equal(split_open("RGB"), 3)
|
||||||
|
if 'zip_encoder' in codecs:
|
||||||
assert_equal(split_open("RGBA"), 4)
|
assert_equal(split_open("RGBA"), 4)
|
||||||
|
|
|
@ -3,6 +3,8 @@ from tester import *
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
from PIL import ImageFile
|
from PIL import ImageFile
|
||||||
|
|
||||||
|
codecs = dir(Image.core)
|
||||||
|
|
||||||
# save original block sizes
|
# save original block sizes
|
||||||
MAXBLOCK = ImageFile.MAXBLOCK
|
MAXBLOCK = ImageFile.MAXBLOCK
|
||||||
SAFEBLOCK = ImageFile.SAFEBLOCK
|
SAFEBLOCK = ImageFile.SAFEBLOCK
|
||||||
|
@ -31,6 +33,7 @@ def test_parser():
|
||||||
assert_image_equal(*roundtrip("GIF"))
|
assert_image_equal(*roundtrip("GIF"))
|
||||||
assert_image_equal(*roundtrip("IM"))
|
assert_image_equal(*roundtrip("IM"))
|
||||||
assert_image_equal(*roundtrip("MSP"))
|
assert_image_equal(*roundtrip("MSP"))
|
||||||
|
if "zip_encoder" in codecs:
|
||||||
try:
|
try:
|
||||||
# force multiple blocks in PNG driver
|
# force multiple blocks in PNG driver
|
||||||
ImageFile.MAXBLOCK = 8192
|
ImageFile.MAXBLOCK = 8192
|
||||||
|
@ -44,6 +47,7 @@ def test_parser():
|
||||||
assert_image_equal(*roundtrip("TGA"))
|
assert_image_equal(*roundtrip("TGA"))
|
||||||
assert_image_equal(*roundtrip("PCX"))
|
assert_image_equal(*roundtrip("PCX"))
|
||||||
|
|
||||||
|
if "jpeg_encoder" in codecs:
|
||||||
im1, im2 = roundtrip("JPEG") # lossy compression
|
im1, im2 = roundtrip("JPEG") # lossy compression
|
||||||
assert_image(im1, im2.mode, im2.size)
|
assert_image(im1, im2.mode, im2.size)
|
||||||
|
|
||||||
|
@ -55,6 +59,9 @@ def test_safeblock():
|
||||||
|
|
||||||
im1 = lena()
|
im1 = lena()
|
||||||
|
|
||||||
|
if "zip_encoder" not in codecs:
|
||||||
|
skip("PNG (zlib) encoder not available")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ImageFile.SAFEBLOCK = 1
|
ImageFile.SAFEBLOCK = 1
|
||||||
im2 = fromstring(tostring(im1, "PNG"))
|
im2 = fromstring(tostring(im1, "PNG"))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user