Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from escpos.printer import Usb
- from PIL import Image
- import os, sys
- #########################################################
- # change these lines to adapt the script to your needs #
- #########################################################
- file = "print.png" # filename - adapt to your needs
- mm_h = 64 # width of the print - 64mm is the max our printer can handle in its current configuration
- #cutmode = 'PART' # select if you want a full or partial cut
- cutmode = 'FULL'
- #########################################################
- im = Image.open(file) # read the image file
- p = Usb(0x03f0, 0x0517) # set device/vendor id
- inch_h = mm_h*0.0393701 # some math following to scale the images correctly
- dpi_h = 203 # keeping the original ratio and scaling for maximum width
- dpi_v = 184 # manual says the vertical dpi should be 180 - 184 are needed for the correct aspect ratio
- size_h = int(inch_h * dpi_h)
- size_v = int(inch_h * (im.height/float(im.width)) * dpi_v)
- size = size_h, size_v
- im = im.resize((size_h,size_v),Image.ANTIALIAS) # resize the image
- p.image(im) # print
- p.cut(mode=cutmode) # cut
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement