davehansen’s posterous

« Back to blog

Convert files to JPEG w/ Python/PIL

Convert files to JPEG

 import os, sys
import Image

 for infile in sys.argv[1:]:
  f, e = os.path.splitext(infile)
  outfile = f + ".jpg"
  if infile != outfile:
  try:
  Image.open(infile).save(outfile)
  except IOError:
  print "cannot convert", infile

Loading mentions Retweet

Comments (0)

Leave a comment...

 
To leave a comment on this posterous, please login by clicking one of the following.
Posterous-login     Connect     twitter