mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-27 10:26:19 +03:00
Merge pull request #5470 from radarhere/wmf_dpi_rounding
Removed WMF DPI rounding
This commit is contained in:
commit
d53a664866
Binary file not shown.
|
@ -44,14 +44,9 @@ def test_register_handler(tmp_path):
|
||||||
WmfImagePlugin.register_handler(original_handler)
|
WmfImagePlugin.register_handler(original_handler)
|
||||||
|
|
||||||
|
|
||||||
def test_load_dpi_rounding():
|
def test_load_float_dpi():
|
||||||
# Round up
|
|
||||||
with Image.open("Tests/images/drawing.emf") as im:
|
with Image.open("Tests/images/drawing.emf") as im:
|
||||||
assert im.info["dpi"] == 1424
|
assert im.info["dpi"] == 1423.7668161434979
|
||||||
|
|
||||||
# Round down
|
|
||||||
with Image.open("Tests/images/drawing_roundDown.emf") as im:
|
|
||||||
assert im.info["dpi"] == 1426
|
|
||||||
|
|
||||||
|
|
||||||
def test_load_set_dpi():
|
def test_load_set_dpi():
|
||||||
|
|
|
@ -127,8 +127,8 @@ class WmfStubImageFile(ImageFile.StubImageFile):
|
||||||
size = x1 - x0, y1 - y0
|
size = x1 - x0, y1 - y0
|
||||||
|
|
||||||
# calculate dots per inch from bbox and frame
|
# calculate dots per inch from bbox and frame
|
||||||
xdpi = int(2540.0 * (x1 - y0) / (frame[2] - frame[0]) + 0.5)
|
xdpi = 2540.0 * (x1 - y0) / (frame[2] - frame[0])
|
||||||
ydpi = int(2540.0 * (y1 - y0) / (frame[3] - frame[1]) + 0.5)
|
ydpi = 2540.0 * (y1 - y0) / (frame[3] - frame[1])
|
||||||
|
|
||||||
self.info["wmf_bbox"] = x0, y0, x1, y1
|
self.info["wmf_bbox"] = x0, y0, x1, y1
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ class WmfStubImageFile(ImageFile.StubImageFile):
|
||||||
|
|
||||||
def load(self, dpi=None):
|
def load(self, dpi=None):
|
||||||
if dpi is not None and self._inch is not None:
|
if dpi is not None and self._inch is not None:
|
||||||
self.info["dpi"] = int(dpi + 0.5)
|
self.info["dpi"] = dpi
|
||||||
x0, y0, x1, y1 = self.info["wmf_bbox"]
|
x0, y0, x1, y1 = self.info["wmf_bbox"]
|
||||||
self._size = (
|
self._size = (
|
||||||
(x1 - x0) * self.info["dpi"] // self._inch,
|
(x1 - x0) * self.info["dpi"] // self._inch,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user