Created
May 6, 2014 15:24
-
-
Save miau/756fb8b14e33c6bb837e to your computer and use it in GitHub Desktop.
Scripts to research ScanSnap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Image | |
import ImageDraw | |
import shutil | |
import tempfile | |
import os | |
img = Image.new('RGB', (5224, 5224), (220, 230, 232)) | |
dr = ImageDraw.Draw(img) | |
dr.rectangle(((1000, 1000), (4999, 4999)), (255, 255, 255), (255, 255, 255)) | |
dr.rectangle(((1010, 1010), (1019, 1019)), (255, 0, 0), (255, 0, 0)) | |
dr.rectangle(((4980, 1010), (4989, 1019)), (255, 0, 0), (255, 0, 0)) | |
dr.rectangle(((1010, 4980), (1019, 4989)), (255, 0, 0), (255, 0, 0)) | |
dr.rectangle(((4980, 4980), (4989, 4989)), (255, 0, 0), (255, 0, 0)) | |
tempdir1 = tempfile.mkdtemp() | |
tempdir2 = tempfile.mkdtemp() | |
img.save(tempdir1 + "/ScanSnap0.png") | |
os.system('C:\LEADCMD\Bin\LFC.exe "%s" "%s" /F=FILE_JPEG /NOUI' % (tempdir1, tempdir2)) | |
shutil.copy(tempdir2 + '/ScanSnap0.jpg', './ScanSnap0.raw') | |
shutil.copy(tempdir2 + '/ScanSnap0.jpg', './ScanSnap1.raw') | |
shutil.rmtree(tempdir1) | |
shutil.rmtree(tempdir2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import sys | |
f = open(sys.argv[1], 'rb') | |
line = f.readline() | |
page = 1 | |
while line: | |
m = re.search(r'<</Subtype/Image/Length (\d+)/', line) | |
if not m is None: | |
len = int(m.group(1)) | |
outfile = '%d.jpg' % page | |
print outfile | |
out = open(outfile, 'wb') | |
out.write(f.read(len)) | |
out.close() | |
page += 1 | |
line = f.readline() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment