From 126dde8a7e04525df5b6249d37a959d2699ebd99 Mon Sep 17 00:00:00 2001 From: Thomas van den Berg Date: Wed, 27 Feb 2013 13:42:32 +0100 Subject: [PATCH] add support for printing PIL image objects directly --- escpos/escpos.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/escpos/escpos.py b/escpos/escpos.py index 3267125..d7ea18e 100644 --- a/escpos/escpos.py +++ b/escpos/escpos.py @@ -8,6 +8,7 @@ import Image import time +import os from constants import * from exceptions import * @@ -60,8 +61,10 @@ class Escpos: switch = 0 img_size = [ 0, 0 ] - im_open = Image.open(img) - im = im_open.convert("RGB") + if isinstance(img, Image): + im = img.convert("RGB") + else: + im = Image.open(img).convert("RGB") if im.size[0] > 512: print "WARNING: Image is wider than 512 and could be truncated at print time "