mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 17:36:18 +03:00
Merge pull request #2102 from radarhere/dpi
Convert DPI to ints when saving as JPEG
This commit is contained in:
commit
9415fb7e3c
|
@ -593,7 +593,7 @@ def _save(im, fp, filename):
|
|||
|
||||
info = im.encoderinfo
|
||||
|
||||
dpi = info.get("dpi", (0, 0))
|
||||
dpi = [int(round(x)) for x in info.get("dpi", (0, 0))]
|
||||
|
||||
quality = info.get("quality", 0)
|
||||
subsampling = info.get("subsampling", -1)
|
||||
|
|
|
@ -469,6 +469,19 @@ class TestFileJpeg(PillowTestCase):
|
|||
img = Image.new(mode, (20, 20))
|
||||
self.assert_warning(DeprecationWarning, img.save, out, "JPEG")
|
||||
|
||||
def test_save_tiff_with_dpi(self):
|
||||
# Arrange
|
||||
outfile = self.tempfile("temp.tif")
|
||||
im = Image.open("Tests/images/hopper.tif")
|
||||
|
||||
# Act
|
||||
im.save(outfile, 'JPEG', dpi=im.info['dpi'])
|
||||
|
||||
# Assert
|
||||
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