forked from rooreynolds/microprinter
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathprint_image_hires.py
More file actions
35 lines (26 loc) · 776 Bytes
/
print_image_hires.py
File metadata and controls
35 lines (26 loc) · 776 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import sys, os
import Image
from microprinter import Microprinter
from microprinter_image import print_image
if len(sys.argv) < 4:
print "Usage: ./print_image_hires.py {ArduinoSerialport} {paper width} {path/to/image} {path/to/image} etc"
print "paper width (in mm) - eg 57, 58 or 80"
print "Example: ./print_image_hires.py /dev/ttyUSB0 58 /home/ben/image.png"
sys.exit(1)
m = Microprinter(sys.argv[1])
width = int(sys.argv[2])
if 55 < width <59:
width = 432
elif width == 80:
width = 576
mode = 33
for infile in sys.argv[3:]:
try:
im = Image.open(infile)
print "Sending %s to the printer" % infile
print_image(im, width, mode, m)
m.feed()
m.feed(5)
m.cut()
except IOError:
pass