mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-13 05:06:49 +03:00
Removed DPI rounding from PNG loading
This commit is contained in:
parent
8354fa4929
commit
9d72542c08
|
@ -386,25 +386,12 @@ class TestFilePng:
|
||||||
# Check dpi roundtripping
|
# Check dpi roundtripping
|
||||||
|
|
||||||
with Image.open(TEST_PNG_FILE) as im:
|
with Image.open(TEST_PNG_FILE) as im:
|
||||||
im = roundtrip(im, dpi=(100, 100))
|
im = roundtrip(im, dpi=(100.33, 100.33))
|
||||||
assert im.info["dpi"] == (100, 100)
|
assert im.info["dpi"] == (100.33, 100.33)
|
||||||
|
|
||||||
def test_load_dpi_rounding(self):
|
def test_load_float_dpi(self):
|
||||||
# Round up
|
|
||||||
with Image.open(TEST_PNG_FILE) as im:
|
with Image.open(TEST_PNG_FILE) as im:
|
||||||
assert im.info["dpi"] == (96, 96)
|
assert im.info["dpi"] == (95.9866, 95.9866)
|
||||||
|
|
||||||
# Round down
|
|
||||||
with Image.open("Tests/images/icc_profile_none.png") as im:
|
|
||||||
assert im.info["dpi"] == (72, 72)
|
|
||||||
|
|
||||||
def test_save_dpi_rounding(self):
|
|
||||||
with Image.open(TEST_PNG_FILE) as im:
|
|
||||||
im = roundtrip(im, dpi=(72.2, 72.2))
|
|
||||||
assert im.info["dpi"] == (72, 72)
|
|
||||||
|
|
||||||
im = roundtrip(im, dpi=(72.8, 72.8))
|
|
||||||
assert im.info["dpi"] == (73, 73)
|
|
||||||
|
|
||||||
def test_roundtrip_text(self):
|
def test_roundtrip_text(self):
|
||||||
# Check text roundtripping
|
# Check text roundtripping
|
||||||
|
|
|
@ -500,7 +500,7 @@ class PngStream(ChunkStream):
|
||||||
px, py = i32(s, 0), i32(s, 4)
|
px, py = i32(s, 0), i32(s, 4)
|
||||||
unit = s[8]
|
unit = s[8]
|
||||||
if unit == 1: # meter
|
if unit == 1: # meter
|
||||||
dpi = int(px * 0.0254 + 0.5), int(py * 0.0254 + 0.5)
|
dpi = px * 0.0254, py * 0.0254
|
||||||
self.im_info["dpi"] = dpi
|
self.im_info["dpi"] = dpi
|
||||||
elif unit == 0:
|
elif unit == 0:
|
||||||
self.im_info["aspect"] = px, py
|
self.im_info["aspect"] = px, py
|
||||||
|
|
Loading…
Reference in New Issue
Block a user