Skip to content

Commit 23023de

Browse files
authored
Merge pull request #8485 from radarhere/emf
2 parents 1654eea + 5557908 commit 23023de

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

Tests/test_file_wmf.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
from io import BytesIO
34
from pathlib import Path
45
from typing import IO
56

@@ -61,6 +62,12 @@ def test_load_float_dpi() -> None:
6162
with Image.open("Tests/images/drawing.emf") as im:
6263
assert im.info["dpi"] == 1423.7668161434979
6364

65+
with open("Tests/images/drawing.emf", "rb") as fp:
66+
data = fp.read()
67+
b = BytesIO(data[:8] + b"\x06\xFA" + data[10:])
68+
with Image.open(b) as im:
69+
assert im.info["dpi"][0] == 2540
70+
6471

6572
def test_load_set_dpi() -> None:
6673
with Image.open("Tests/images/drawing.wmf") as im:

src/PIL/WmfImagePlugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def _open(self) -> None:
128128
size = x1 - x0, y1 - y0
129129

130130
# calculate dots per inch from bbox and frame
131-
xdpi = 2540.0 * (x1 - y0) / (frame[2] - frame[0])
131+
xdpi = 2540.0 * (x1 - x0) / (frame[2] - frame[0])
132132
ydpi = 2540.0 * (y1 - y0) / (frame[3] - frame[1])
133133

134134
self.info["wmf_bbox"] = x0, y0, x1, y1

0 commit comments

Comments
 (0)