Skip to content

Instantly share code, notes, and snippets.

@radaniba
Last active December 13, 2015 21:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save radaniba/4980787 to your computer and use it in GitHub Desktop.
Save radaniba/4980787 to your computer and use it in GitHub Desktop.
A simple script to convert named PDFs to PNGs of the equivalent name.the use case here is that I had a program that churned out graphs as PDFs (and PDFs only) and needed to include these graphs in another document (webpages in this case). This script takes the PDFs and runs them on the commandline through a simple programs called "sips", naming …
import sys
from os import path, system
# for each file
for infile in sys.argv[1:]:
# extract filename components
base, ext = path.splitext (infile)
new_name = base + ".png"
print "Converting %s to %s ..." % (infile, new_name)
system ("sips -s format png \"%s\" --out \"%s\"" % (infile, new_name))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment