27 lines
575 B
Python
27 lines
575 B
Python
dev_path="/dev/usb/lp0"
|
|
from format_image import format_image
|
|
from PIL import Image
|
|
import os
|
|
|
|
def print_text(text):
|
|
stream = open('/dev/usb/lp0', 'wb')
|
|
stream.write(text.encode('utf-8'))
|
|
stream.close()
|
|
|
|
def cut_paper():
|
|
stream = open('/dev/usb/lp0', 'wb')
|
|
stream.write(b'\x1DV\x41\0')
|
|
stream.close()
|
|
|
|
def print_image(image):
|
|
image.save("/tmp/image.png")
|
|
|
|
# I'm sorry
|
|
os.system("cd epson/; ./print_image.sh /tmp/image.png; cd ..")
|
|
|
|
image = format_image("static/text/text.png")
|
|
image.save("/tmp/image.png")
|
|
print_image(image)
|
|
cut_paper()
|
|
|
|
|