mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-04 20:03:20 +03:00
BMP now uses a reasonable resolution, and customizable using the "dpi" option.
This commit is contained in:
parent
3f5b15ff31
commit
103354facc
|
@ -203,6 +203,13 @@ def _save(im, fp, filename, check=0):
|
||||||
if check:
|
if check:
|
||||||
return check
|
return check
|
||||||
|
|
||||||
|
info = im.encoderinfo
|
||||||
|
|
||||||
|
dpi = info.get("dpi", (96, 96))
|
||||||
|
|
||||||
|
# 1 meter == 39.3701 inches
|
||||||
|
ppm = map(lambda x: int(x * 39.3701), dpi)
|
||||||
|
|
||||||
stride = ((im.size[0]*bits+7)//8+3)&(~3)
|
stride = ((im.size[0]*bits+7)//8+3)&(~3)
|
||||||
header = 40 # or 64 for OS/2 version 2
|
header = 40 # or 64 for OS/2 version 2
|
||||||
offset = 14 + header + colors * 4
|
offset = 14 + header + colors * 4
|
||||||
|
@ -222,7 +229,7 @@ def _save(im, fp, filename, check=0):
|
||||||
o16(bits) + # depth
|
o16(bits) + # depth
|
||||||
o32(0) + # compression (0=uncompressed)
|
o32(0) + # compression (0=uncompressed)
|
||||||
o32(image) + # size of bitmap
|
o32(image) + # size of bitmap
|
||||||
o32(1) + o32(1) + # resolution
|
o32(ppm[0]) + o32(ppm[1]) + # resolution
|
||||||
o32(colors) + # colors used
|
o32(colors) + # colors used
|
||||||
o32(colors)) # colors important
|
o32(colors)) # colors important
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user