mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-08-16 18:24:45 +03:00
Merge 634740cad8
into 8846e99e84
This commit is contained in:
commit
93b894a5ab
|
@ -1154,9 +1154,9 @@ class TiffImageFile(ImageFile.ImageFile):
|
|||
if xres and yres:
|
||||
resunit = self.tag_v2.get(RESOLUTION_UNIT, 1)
|
||||
if resunit == 2: # dots per inch
|
||||
self.info["dpi"] = xres, yres
|
||||
self.info["dpi"] = int(round(xres)), int(round(yres))
|
||||
elif resunit == 3: # dots per centimeter. convert to dpi
|
||||
self.info["dpi"] = xres * 2.54, yres * 2.54
|
||||
self.info["dpi"] = int(round(xres * 2.54)), int(round(yres * 2.54))
|
||||
else: # No absolute unit of measurement
|
||||
self.info["resolution"] = xres, yres
|
||||
|
||||
|
|
|
@ -470,6 +470,20 @@ class TestFileTiff(PillowTestCase):
|
|||
im = Image.open(infile)
|
||||
self.assertEqual(im.getpixel((0, 0)), pixel_value)
|
||||
|
||||
def test_save_tiff_with_dpi(self):
|
||||
|
||||
outfile = self.tempfile("temp.tif")
|
||||
|
||||
infile = "Tests/images/hopper.tif"
|
||||
im = Image.open(infile)
|
||||
|
||||
im.save(outfile, 'JPEG', dpi=im.info['dpi'])
|
||||
|
||||
reloaded = Image.open(outfile)
|
||||
reloaded.load()
|
||||
|
||||
self.assertEqual(im.info['dpi'], reloaded.info['dpi'])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
Loading…
Reference in New Issue
Block a user