diff --git a/Tests/images/hopper.bmp b/Tests/images/hopper.bmp new file mode 100644 index 000000000..785700d22 Binary files /dev/null and b/Tests/images/hopper.bmp differ diff --git a/Tests/test_file_bmp.py b/Tests/test_file_bmp.py index 69792fe12..fd0f29470 100644 --- a/Tests/test_file_bmp.py +++ b/Tests/test_file_bmp.py @@ -49,6 +49,22 @@ class TestFileBmp(PillowTestCase): self.assertEqual(reloaded.info["dpi"], dpi) + def test_save_bmp_with_dpi(self): + # Test for #1301 + # Arrange + outfile = self.tempfile("temp.jpg") + im = Image.open("Tests/images/hopper.bmp") + + # Act + im.save(outfile, 'JPEG', dpi=im.info['dpi']) + + # Assert + reloaded = Image.open(outfile) + reloaded.load() + self.assertEqual(im.info['dpi'], reloaded.info['dpi']) + self.assertEqual(im.size, reloaded.size) + self.assertEqual(reloaded.format, "JPEG") + if __name__ == '__main__': unittest.main()