Pillow/Tests/test_file_wmf.py
glexey 0116c9240e EMF: support negative bounding box coordinates (#2249)
* EMF: support negative bounding box coordinates

Similar to placeable WMF, bounding box coordinates
should be interpreted as signed integer, otherwise
opening EMF file with negative (x0,y0) fails.

* Basic load tests for WMF and EMF formats

* WMF/WMF tests: just test open(), not load()

Not sure why load() fails on Debian build. Well, at least we can test
open().

* WMF/EMF: Unpack signed integers using unpack()

* WMF/EMF: Compare to reference PNG rendering

* EMF/WMF comparison: use assert_image_similar()

* Use similarity epsilon 0.5 for WMF, as vector rendering looks different across Windows platforms

* Trigger rebuild
2016-11-27 16:03:51 +00:00

32 lines
1.0 KiB
Python

from helper import unittest, PillowTestCase
from PIL import Image
from io import BytesIO
class TestFileWmf(PillowTestCase):
def test_load_raw(self):
# Test basic EMF open and rendering
im = Image.open('Tests/images/drawing.emf')
if hasattr(Image.core, "drawwmf"):
# Currently, support for WMF/EMF is Windows-only
im.load()
# Compare to reference rendering
imref = Image.open('Tests/images/drawing_emf_ref.png')
imref.load()
self.assert_image_similar(im, imref, 0)
# Test basic WMF open and rendering
im = Image.open('Tests/images/drawing.wmf')
if hasattr(Image.core, "drawwmf"):
# Currently, support for WMF/EMF is Windows-only
im.load()
# Compare to reference rendering
imref = Image.open('Tests/images/drawing_wmf_ref.png')
imref.load()
self.assert_image_similar(im, imref, 0.5)
if __name__ == '__main__':
unittest.main()