Repository: python-pillow/Pillow

Issue:
wmf file to bitmap was forced to 72 dpi
<!--
2.  Bug report: include a self-contained, copy-pastable example that
    generates the issue if possible. Be concise with code posted.
    Guidelines on how to provide a good bug report:
-->

### What did you do?
I read in an wmf image and then save it as a png image. I found the resolution of the result image is rather low no matter how I set the quality parameters. 

When I looking into the source code ( src/PIL/WmfImagePlugin.py), I found the resolution was fixed to 72dpi.

### What are your OS, Python and Pillow versions?

* OS:  win10
* Python: 3.6.8
* Pillow: 6.1.0


Discussion:
Could you attach the WMF image?
do not support wmf file, @radarhere 

If GitHub won't allow you to upload a WMF file, please zip it and upload the zip file.
[image2.zip](https://github.com/python-pillow/Pillow/files/3886606/image2.zip)
Lucky, zip is permitted. 
For now, I think you should be able to use this code to set the size that the image is rendered at, and so effectively, the DPI that is used to create the image -
```python
from PIL import Image
im = Image.open("test.wmf")
im._size = (300, 300)
im.load()
```

Resolving patch:
diff --git a/src/PIL/WmfImagePlugin.py b/src/PIL/WmfImagePlugin.py
--- a/src/PIL/WmfImagePlugin.py
+++ b/src/PIL/WmfImagePlugin.py
@@ -78,6 +78,7 @@ class WmfStubImageFile(ImageFile.StubImageFile):
     format_description = "Windows Metafile"
 
     def _open(self):
+        self._inch = None
 
         # check placable header
         s = self.fp.read(80)
@@ -87,7 +88,7 @@ def _open(self):
             # placeable windows metafile
 
             # get units per inch
-            inch = word(s, 14)
+            self._inch = word(s, 14)
 
             # get bounding box
             x0 = short(s, 6)
@@ -96,12 +97,14 @@ def _open(self):
             y1 = short(s, 12)
 
             # normalize size to 72 dots per inch
-            size = (x1 - x0) * 72 // inch, (y1 - y0) * 72 // inch
+            self.info["dpi"] = 72
+            size = (
+                (x1 - x0) * self.info["dpi"] // self._inch,
+                (y1 - y0) * self.info["dpi"] // self._inch,
+            )
 
             self.info["wmf_bbox"] = x0, y0, x1, y1
 
-            self.info["dpi"] = 72
-
             # sanity check (standard metafile header)
             if s[22:26] != b"\x01\x00\t\x00":
                 raise SyntaxError("Unsupported WMF file format")
@@ -118,7 +121,6 @@ def _open(self):
             # get frame (in 0.01 millimeter units)
             frame = _long(s, 24), _long(s, 28), _long(s, 32), _long(s, 36)
 
-            # normalize size to 72 dots per inch
             size = x1 - x0, y1 - y0
 
             # calculate dots per inch from bbox and frame
@@ -145,6 +147,16 @@ def _open(self):
     def _load(self):
         return _handler
 
+    def load(self, dpi=None):
+        if dpi is not None and self._inch is not None:
+            self.info["dpi"] = int(dpi + 0.5)
+            x0, y0, x1, y1 = self.info["wmf_bbox"]
+            self._size = (
+                (x1 - x0) * self.info["dpi"] // self._inch,
+                (y1 - y0) * self.info["dpi"] // self._inch,
+            )
+        super().load()
+
 
 def _save(im, fp, filename):
     if _handler is None or not hasattr(_handler, "save"):


Test patch:
diff --git a/Tests/images/drawing_wmf_ref_144.png b/Tests/images/drawing_wmf_ref_144.png
new file mode 100644
Binary files /dev/null and b/Tests/images/drawing_wmf_ref_144.png differ
diff --git a/Tests/test_file_wmf.py b/Tests/test_file_wmf.py
--- a/Tests/test_file_wmf.py
+++ b/Tests/test_file_wmf.py
@@ -53,6 +53,17 @@ def test_load_dpi_rounding(self):
         with Image.open("Tests/images/drawing_roundDown.emf") as im:
             self.assertEqual(im.info["dpi"], 1426)
 
+    def test_load_set_dpi(self):
+        with Image.open("Tests/images/drawing.wmf") as im:
+            self.assertEquals(im.size, (82, 82))
+
+            if hasattr(Image.core, "drawwmf"):
+                im.load(144)
+                self.assertEquals(im.size, (164, 164))
+
+                with Image.open("Tests/images/drawing_wmf_ref_144.png") as expected:
+                    self.assert_image_similar(im, expected, 2.0)
+
     def test_save(self):
         im = hopper()