-
-
Save gregjurman/bd0a1f99eb8f55dda875 to your computer and use it in GitHub Desktop.
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
from wand.image import Image as WandImage | |
import sys | |
if __name__ == '__main__': | |
print "Welcome to wand-text.py!" | |
if len(sys.argv) != 3: | |
print "Usage:\n\n\tpython wand-text.py <input_pdf_filename> <output_image_basename>" | |
print "Ex: \n\n\tpython wand-text.py pdfdocument.pdf page" | |
else: | |
pdf_filename = sys.argv[1] | |
image_filename = sys.argv[2] | |
try: | |
#if True: | |
img = WandImage(filename=pdf_filename, resolution=400) | |
# wand makes image sequences out of multi-page files | |
for i,im in zip(xrange(len(img.sequence)), img.sequence): | |
im.clone().save(filename='%s-%i.jpg' %(image_filename, i)) | |
except Exception, e: | |
print "ERROR: {0}".format(e) | |
print "Exit." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If I had a nickel for every time I wrote 'text' instead of 'test' ...