Skip to content

Instantly share code, notes, and snippets.

@gregjurman
Forked from thequbit/gist:b76ef1153a7e308f6b9b
Last active August 29, 2015 14:05
Show Gist options
  • Save gregjurman/bd0a1f99eb8f55dda875 to your computer and use it in GitHub Desktop.
Save gregjurman/bd0a1f99eb8f55dda875 to your computer and use it in GitHub Desktop.
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."
@thequbit
Copy link

thequbit commented Sep 2, 2014

If I had a nickel for every time I wrote 'text' instead of 'test' ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment