checking results of webp decoding

This commit is contained in:
wiredfool 2013-03-19 13:40:10 -07:00
parent 95353cff15
commit 02931c4956
2 changed files with 17 additions and 6 deletions

Binary file not shown.

View File

@ -2,7 +2,7 @@ from tester import *
from PIL import Image
def test_sanity():
def test_read():
file = "Images/lena.webp"
im = Image.open(file)
@ -10,18 +10,29 @@ def test_sanity():
assert_equal(im.mode, "RGB")
assert_equal(im.size, (128, 128))
assert_equal(im.format, "WEBP")
assert_no_exception(lambda: im.load())
assert_no_exception(lambda: im.getdata())
orig_bytes = im.tobytes()
# generated with: dwebp -ppm ../../Images/lena.webp -o lena_webp_bits.ppm
target = Image.open('Tests/images/lena_webp_bits.ppm')
assert_image_equal(im, target)
def test_write():
file = tempfile("temp.webp")
lena("RGB").save(file)
im = Image.open(file)
im.load()
reloaded= Image.open(file)
reloaded.load()
assert_equal(im.mode, "RGB")
assert_equal(im.size, (128, 128))
assert_equal(im.format, "WEBP")
assert_equal(reloaded.mode, "RGB")
assert_equal(reloaded.size, (128, 128))
assert_equal(reloaded.format, "WEBP")
assert_no_exception(lambda: reloaded.load())
assert_no_exception(lambda: reloaded.getdata())