mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-03 21:24:31 +03:00
Merge pull request #1302 from hugovk/1301_integer_expected
DPI should be tuple of ints, not floats
This commit is contained in:
commit
d29c3937ee
|
@ -103,7 +103,9 @@ class BmpImageFile(ImageFile.ImageFile):
|
|||
file_info['pixels_per_meter'] = (i32(header_data[20:24]), i32(header_data[24:28]))
|
||||
file_info['colors'] = i32(header_data[28:32])
|
||||
file_info['palette_padding'] = 4
|
||||
self.info["dpi"] = tuple(map(lambda x: math.ceil(x / 39.3701), file_info['pixels_per_meter']))
|
||||
self.info["dpi"] = tuple(
|
||||
map(lambda x: int(math.ceil(x / 39.3701)),
|
||||
file_info['pixels_per_meter']))
|
||||
if file_info['compression'] == self.BITFIELDS:
|
||||
if len(header_data) >= 52:
|
||||
for idx, mask in enumerate(['r_mask', 'g_mask', 'b_mask', 'a_mask']):
|
||||
|
|
BIN
Tests/images/hopper.bmp
Normal file
BIN
Tests/images/hopper.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 48 KiB |
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue
Block a user