# SPDX-License-Identifier: GPL-3.0-or-later dev_path="/dev/usb/lp0" from format_image import * from PIL import Image import ctypes import io import time printer = ctypes.CDLL('./epson/library_bridge.so') def print_text(text): time.sleep(0.1) try: printer.print_text(b"/dev/usb/lp0", text.encode('utf-8')) except Exception as e: print(f"An error occurred: {e}") def cut_paper(): time.sleep(0.1) try: printer.cut(b"/dev/usb/lp0") except Exception as e: print(f"An error occurred: {e}") def print_image(image): time.sleep(0.1) Bytes = io.BytesIO() image.save(Bytes, format='PNG') Bytes = Bytes.getvalue() try: printer.print_image(b"/dev/usb/lp0", Bytes, len(Bytes)) except Exception as e: print(f"An error occurred: {e}") # 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()