Allow bypassing the resizing and height-cropping steps in fullimage()
This commit is contained in:
parent
598c893943
commit
a6ec674828
|
@ -184,19 +184,22 @@ class Escpos(object):
|
||||||
n = n + h[i+b]
|
n = n + h[i+b]
|
||||||
im = im.point(lut)
|
im = im.point(lut)
|
||||||
|
|
||||||
ratio = float(width) / im.size[0]
|
if width:
|
||||||
newheight = int(ratio * im.size[1])
|
ratio = float(width) / im.size[0]
|
||||||
|
newheight = int(ratio * im.size[1])
|
||||||
|
|
||||||
# Resize the image
|
# Resize the image
|
||||||
im = im.resize((width, newheight), Image.ANTIALIAS)
|
im = im.resize((width, newheight), Image.ANTIALIAS)
|
||||||
if im.size[1] > max_height:
|
|
||||||
|
if max_height and im.size[1] > max_height:
|
||||||
im = im.crop((0, 0, im.size[0], max_height))
|
im = im.crop((0, 0, im.size[0], max_height))
|
||||||
|
|
||||||
# Divide into bands
|
# Divide into bands
|
||||||
bandsize = 255
|
bandsize = 255
|
||||||
current = 0
|
current = 0
|
||||||
while current < im.size[1]:
|
while current < im.size[1]:
|
||||||
self.image(im.crop((0, current, width, min(im.size[1], current + bandsize))))
|
self.image(im.crop((0, current, width or im.size[0],
|
||||||
|
min(im.size[1], current + bandsize))))
|
||||||
current += bandsize
|
current += bandsize
|
||||||
|
|
||||||
def direct_image(self, image):
|
def direct_image(self, image):
|
||||||
|
|
Loading…
Reference in New Issue