forked from XPUB/si19cutting
Compare commits
12 Commits
Author | SHA1 | Date |
---|---|---|
suzan | 110f699324 | 2 years ago |
cutting | bf525f4fc2 | 2 years ago |
suzan | f1c53c186d | 2 years ago |
cutting | 6d644b6be7 | 2 years ago |
cutting | 35950998d6 | 2 years ago |
suzan | 638d57489b | 2 years ago |
cutting | df6b2f0877 | 2 years ago |
suzan | b72f75630c | 2 years ago |
cutting | 8a4e501054 | 2 years ago |
suzan | 326594c324 | 2 years ago |
cutting | b34ebebf54 | 2 years ago |
joak | 47b2e80299 | 2 years ago |
@ -1,14 +1,43 @@
|
||||
import os
|
||||
import calendar
|
||||
import time
|
||||
|
||||
#-----------------------------------------
|
||||
#pruning
|
||||
print("starting the pruning process")
|
||||
scanning = "sudo scanimage --resolution 300 --mode color -o image.png"
|
||||
scanning = "scanimage --resolution 300 --mode gray --format png > image.png"
|
||||
os.system(scanning)
|
||||
os.system("tesseract image.png text.txt -l eng")
|
||||
fantasyname = open("text.txt.txt" , "r")
|
||||
os.system("convert -contrast image.png output.png")
|
||||
os.system("tesseract output.png image -l eng")
|
||||
fantasyname = open("image.txt" , "r")
|
||||
fantasyname = fantasyname.readlines()
|
||||
for line in fantasyname:
|
||||
line = line.split(" ")
|
||||
for l in line:
|
||||
if l!="" or l != ['\n', '\r\n']:
|
||||
print(l)
|
||||
os.system("echo '"+l+"' > /dev/usb/lp0")
|
||||
text = open("image.txt", "r").read()
|
||||
text = text.replace(b'\xe2\x80\x98'.decode(), "'")
|
||||
text = text.replace(b'\xe2\x80\x99'.decode(), "'")
|
||||
text = text.replace(b'\xe2\x80\x9d'.decode(), "'")
|
||||
text = text.replace(b'\xe2\x80\x9c'.decode(), "'")
|
||||
#-------------------------------------------------------------
|
||||
#printing
|
||||
print(text)
|
||||
print("------")
|
||||
lines = text.split("\n")
|
||||
for line in lines:
|
||||
dotprint = f'echo "{ line }" > /dev/usb/lp0'
|
||||
os.system(dotprint)
|
||||
#for line in fantasyname:
|
||||
#line = line.split(" ")
|
||||
#for l in line:
|
||||
#if l!="" or l != ['\n', '\r\n']:
|
||||
#print(l)
|
||||
#os.system("echo '"+l+"' > /dev/usb/lp0")
|
||||
#-------------------------------------------------------------------
|
||||
#copying
|
||||
print("copying the scan")
|
||||
current_GMT = time.gmtime()
|
||||
ts = calendar.timegm(current_GMT)
|
||||
#print(ts)
|
||||
|
||||
# First make a folder, for example called "scans"
|
||||
# Then you can use this to write new filenames
|
||||
copy_command = f"cp image.png scans/image-{ ts }.png"
|
||||
os.system(copy_command)
|
||||
|
Loading…
Reference in New Issue