From 18e204df05b534220a1e6330bd398c9c5a358f1d Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Fri, 7 May 2021 21:23:29 +1000 Subject: [PATCH] Removed DPI rounding from JPEG loading --- Tests/images/iptc_roundDown.jpg | Bin 21019 -> 0 bytes Tests/test_file_jpeg.py | 9 --------- src/PIL/JpegImagePlugin.py | 7 +++++-- 3 files changed, 5 insertions(+), 11 deletions(-) delete mode 100644 Tests/images/iptc_roundDown.jpg diff --git a/Tests/images/iptc_roundDown.jpg b/Tests/images/iptc_roundDown.jpg deleted file mode 100644 index f98206f1826f1844f1767cbb694f830de4ed403c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 21019 zcmeFYc|26_|37?Y27~MdV_##2$TDO%2xDh#k;+zPC|OcbG7@F%*(WiWv1=t%N{b~? z_Owa%U5b({_ZfP>KcDY?-+$b{`@i4g@jH*lne%d;>s;rxJYUOooy+#n_5wh1Ae=sP zI*f2SSV}`h70@=Zv}Ixf7>BPI)B|8O3HS33J|1>P40;@Z?nw=+}002u%MSvB2 zEi1qcfdVWb6$G9T( zWU&1kIDp;hK%zHbcR*EH4cG_%%^35as~|wRygPa>*nIOZO$BL%Yr7*xfxUq=IKWVp zs=B%=EDZ`EK)M|4!}OPa4APMF-98WoC)e3`-qH=WL$B|SKLpaO*LTNc49WIiH2dE^ zBVZqZ`uAOGs;Us`f24v^ccsFD>Vo~H?|@7}X#W`#`d>8czi1}fE)Ub-_$>d`4*yFt zUduSf#Q*?n!VO4)G&^`Q?5(SMKvz{;N?lD?4Wo@MLiO&vkof`y+4# zV1_X|x{J<>uq#<>uw(7ZelXM~DdU@*<^?BI4qbl9K#F zGIBB!a$*va5)kk)I18MMm6b~Z!HbaiUp}^*0bW+%JV1p(qyZ=|1jY;5ehDcCnPrCT z91P|e2M7@+kV95B_B}iR6as@mLB2u8!8=h5_%QJ@^GT~2v+z55!(~Dc>M`j>tgCEu)Ivn(rPSx#*T3B5Pli;7*>QydePlyY_b~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I#}aQzMEk-a7GTuJYxQ}V*? zz#BCGz>tAV8F1-+2rCL!Q=IkzlFxJL{h1GoqB3Y3TTwBDcuF!S2c4oY+L8hXlW<=& z2?+WE0@3kXm@JW}Tw_P3#K1Eqd-Dh4YHIjjG(KqpwclUbqcAqk2aB0bdM3fbql1kD zNZcFMalsd>WJ&LqM%T)#9V%^!Akoqui{y?q8pZ_g5MFeVXnpBI^0UNy(?mh-MCpm) zq%+@I^&ZO^HbPa3dm_>wTbD7r$4iU4Z6wA`y1@)=Yx|8zQ2pv@a&SvmGc(33+B_p& cy9|9qW10^edIHde?REap2Fe*F!oU3c|F1yA2mk;8 diff --git a/Tests/test_file_jpeg.py b/Tests/test_file_jpeg.py index ab799c13f..eb566e687 100644 --- a/Tests/test_file_jpeg.py +++ b/Tests/test_file_jpeg.py @@ -656,15 +656,6 @@ class TestFileJpeg: reloaded.load() assert im.info["dpi"] == reloaded.info["dpi"] - def test_load_dpi_rounding(self): - # Round up - with Image.open("Tests/images/iptc_roundUp.jpg") as im: - assert im.info["dpi"] == (44, 44) - - # Round down - with Image.open("Tests/images/iptc_roundDown.jpg") as im: - assert im.info["dpi"] == (2, 2) - def test_save_dpi_rounding(self, tmp_path): outfile = str(tmp_path / "temp.jpg") with Image.open("Tests/images/hopper.jpg") as im: diff --git a/src/PIL/JpegImagePlugin.py b/src/PIL/JpegImagePlugin.py index f449a2dc0..6d4bc70c5 100644 --- a/src/PIL/JpegImagePlugin.py +++ b/src/PIL/JpegImagePlugin.py @@ -33,6 +33,7 @@ # import array import io +import math import os import struct import subprocess @@ -162,15 +163,17 @@ def APP(self, marker): dpi = float(x_resolution[0]) / x_resolution[1] except TypeError: dpi = x_resolution + if math.isnan(dpi): + raise ValueError if resolution_unit == 3: # cm # 1 dpcm = 2.54 dpi dpi *= 2.54 - self.info["dpi"] = int(dpi + 0.5), int(dpi + 0.5) + self.info["dpi"] = dpi, dpi except (KeyError, SyntaxError, ValueError, ZeroDivisionError): # SyntaxError for invalid/unreadable EXIF # KeyError for dpi not included # ZeroDivisionError for invalid dpi rational value - # ValueError for x_resolution[0] being an invalid float + # ValueError for dpi being an invalid float self.info["dpi"] = 72, 72