1
0
mirror of https://github.com/python-escpos/python-escpos synced 2025-09-13 09:09:58 +00:00

improve large image printing

images longer than 1024 pixels will be split into multiple fragments.
This commit is contained in:
Patrick Kanzler
2016-08-01 14:39:44 +02:00
parent 10977b06e7
commit 2ecf73074c
2 changed files with 40 additions and 1 deletions

View File

@@ -56,7 +56,8 @@ class Escpos(object):
"""
pass
def image(self, img_source, high_density_vertical=True, high_density_horizontal=True, impl="bitImageRaster"):
def image(self, img_source, high_density_vertical=True, high_density_horizontal=True, impl="bitImageRaster",
fragment_height=1024):
""" Print an image
You can select whether the printer should print in high density or not. The default value is high density.
@@ -76,9 +77,20 @@ class Escpos(object):
:param high_density_vertical: print in high density in vertical direction *default:* True
:param high_density_horizontal: print in high density in horizontal direction *default:* True
:param impl: choose image printing mode between `bitImageRaster`, `graphics` or `bitImageColumn`
:param fragment_height: Images larger than this will be split into multiple fragments *default:* 1024
"""
im = EscposImage(img_source)
if im.height > fragment_height:
fragments = im.split(fragment_height)
for fragment in fragments:
self.image(fragment,
high_density_vertical=high_density_vertical,
high_density_horizontal=high_density_horizontal,
impl=impl,
fragment_height=fragment_height)
return
if impl == "bitImageRaster":
# GS v 0, raster format bit image