#!/usr/bin/python

import os, sys
import Image


def rot(inf,outf):
    im = Image.open(inf)
    im.rotate(270).save(outf, "JPEG")
#    im.save(outf, "JPEG")

if __name__=="__main__":
  for infile in sys.argv[1:]:
    outfile = os.path.splitext(infile)[0] + "_r" + os.path.splitext(infile)[1]
    print infile, outfile
    if infile != outfile:
      rot(infile,outfile)
#        try:
#        except IOError:
 #           print "cannot create thumbnail for", infile


