mirror of
https://github.com/python-escpos/python-escpos
synced 2025-09-13 09:09:58 +00:00
add support for printing PIL image objects directly
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
import Image
|
import Image
|
||||||
import time
|
import time
|
||||||
|
import os
|
||||||
|
|
||||||
from constants import *
|
from constants import *
|
||||||
from exceptions import *
|
from exceptions import *
|
||||||
@@ -60,8 +61,10 @@ class Escpos:
|
|||||||
switch = 0
|
switch = 0
|
||||||
img_size = [ 0, 0 ]
|
img_size = [ 0, 0 ]
|
||||||
|
|
||||||
im_open = Image.open(img)
|
if isinstance(img, Image):
|
||||||
im = im_open.convert("RGB")
|
im = img.convert("RGB")
|
||||||
|
else:
|
||||||
|
im = Image.open(img).convert("RGB")
|
||||||
|
|
||||||
if im.size[0] > 512:
|
if im.size[0] > 512:
|
||||||
print "WARNING: Image is wider than 512 and could be truncated at print time "
|
print "WARNING: Image is wider than 512 and could be truncated at print time "
|
||||||
|
Reference in New Issue
Block a user