#!/usr/bin/python
import sys,os,string
from Foundation import NSNumber
from AppKit import NSImage
from QTKit import *

def process(file):
    outfileName = string.join([os.path.splitext(file)[0],"mov"],".")
    print "creating ",outfileName
    mov, err = QTMovie.alloc().initToWritableFile_error_(outfileName, None)
    if mov is None:
        errmsg = "Could not create movie file: %s" % (outfileName)
        raise IOError, errmsg
    img = NSImage.alloc().initWithContentsOfFile_(file)
    mov.addImage_forDuration_withAttributes_(img, time, attrs)
    mov.updateMovieFile()

time = QTMakeTime(20, 600)
attrs = {QTAddImageCodecType: "jpeg", QTAddImageCodecQuality: NSNumber.numberWithLong_(codecHighQuality)}
for f in sys.argv[1:]:
    process(f)

