mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-08-17 18:54:46 +03:00
WMF/EMF: Compare to reference PNG rendering
This commit is contained in:
parent
c7faca7e0f
commit
b06103acc7
|
@ -1,9 +1,21 @@
|
||||||
from helper import unittest, PillowTestCase
|
from helper import unittest, PillowTestCase
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
from io import BytesIO
|
||||||
|
|
||||||
|
|
||||||
class TestFileWmf(PillowTestCase):
|
class TestFileWmf(PillowTestCase):
|
||||||
|
|
||||||
|
def as_png(self, im):
|
||||||
|
# Pass the image through PNG save/load
|
||||||
|
out = BytesIO()
|
||||||
|
im.save(out, "PNG")
|
||||||
|
test_bytes = out.tell()
|
||||||
|
out.seek(0)
|
||||||
|
im = Image.open(out)
|
||||||
|
im.bytes = test_bytes # for testing only
|
||||||
|
im.load()
|
||||||
|
return im
|
||||||
|
|
||||||
def test_load_raw(self):
|
def test_load_raw(self):
|
||||||
|
|
||||||
# Test basic EMF open and rendering
|
# Test basic EMF open and rendering
|
||||||
|
@ -14,7 +26,7 @@ class TestFileWmf(PillowTestCase):
|
||||||
# Compare to reference rendering
|
# Compare to reference rendering
|
||||||
imref = Image.open('Tests/images/drawing_emf_ref.png')
|
imref = Image.open('Tests/images/drawing_emf_ref.png')
|
||||||
imref.load()
|
imref.load()
|
||||||
self.assert_image_equal(im, imref)
|
self.assert_image_equal(self.as_png(im), imref)
|
||||||
|
|
||||||
# Test basic WMF open and rendering
|
# Test basic WMF open and rendering
|
||||||
im = Image.open('Tests/images/drawing.wmf')
|
im = Image.open('Tests/images/drawing.wmf')
|
||||||
|
@ -24,7 +36,7 @@ class TestFileWmf(PillowTestCase):
|
||||||
# Compare to reference rendering
|
# Compare to reference rendering
|
||||||
imref = Image.open('Tests/images/drawing_wmf_ref.png')
|
imref = Image.open('Tests/images/drawing_wmf_ref.png')
|
||||||
imref.load()
|
imref.load()
|
||||||
self.assert_image_equal(im, imref)
|
self.assert_image_equal(self.as_png(im), imref)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Loading…
Reference in New Issue
Block a user