Here is an example of calling this function:#---------------------------------------------------------------------- #saveMovieToFile - Write a list of pictures to files in order. #movie - A list of pictures. #dir - The directory where the pictures should be saved. #name - The starting portion of the filenames. For example if name is "box" # the filenames will look like "box000.jpg", "box001.jpg" etc. #firstFrame - Where to start numbering frames. For example if this is 4, # the first file will be named "box004.jpg". #---------------------------------------------------------------------- import os def saveMovieToFile(movie, dir, name, firstFrame): curFrame = firstFrame for index in range(len(movie)): if isinstance(movie[index], Picture): curName = os.path.join(dir, name + "%03i" % curFrame + ".jpg") print curName writePictureTo(movie[index], curName) curFrame= curFrame+1
The function>>> saveMovieToFile(movieA, pickAFolder(), 'rectangle', 0) >>> saveMovieToFile(movieB, pickAFolder(), 'rectangle', 3)
pickAFolder()
will open a window for you to
choose the folder in which you would like to store the pictures. Now, assuming that movieA and movieB are lists containing three pictures
each, and the Movies subfolder within the CS107 folder on the user's M:
drive was chosen, the result will be the creation of the following 6 files:
M:/CS107/Movies/rectangle000.jpg M:/CS107/Movies/rectangle001.jpg M:/CS107/Movies/rectangle002.jpg M:/CS107/Movies/rectangle003.jpg (movieB starts here) M:/CS107/Movies/rectangle004.jpg M:/CS107/Movies/rectangle005.jpg