@@ -0,0 +1,2150 @@
+import FlyMovieFormat%0Aimport Image%0Aimport numpy as np%0Aimport argparse%0A%0Amode2format = %7B'L':'MONO8',%0A               'RGB':'RGB8',%0A              %7D%0A%0Adef images2fmf( input_filenames, out_fname, version=3 ):%0A    %22%22%22convert a series of images into an .fmf file%0A%0A    arguments%0A    ---------%0A%0A    input_filenames: a list of strings of filenames %5B'filename1.png','filename2.png'%5D%0A    out_fname: an output filename for the resulting .fmf movie%0A    version: a version specifier for the output .fmf%0A%0A    notes%0A    -----%0A%0A    The input images must be have the same width, height and mode. The%0A    order in which they are specified is the order saved into the new%0A    .fmf movie. Timestamps are generated from framenumbers starting%0A    from zero.%0A%0A    %22%22%22%0A    im_size = None%0A    im_mode = None%0A    fmf_out = None%0A%0A    for timestamp,in_fname in enumerate(input_filenames):%0A        im = Image.open(in_fname)%0A        if im_size is None:%0A            im_size = im.size%0A            im_mode = im.mode%0A        else:%0A            assert im_size == im.size%0A            assert im_mode == im.mode%0A        buf = im.tostring()%0A%0A        if fmf_out is None:%0A            fmf_out = FlyMovieFormat.FlyMovieSaver(out_fname,%0A                                                   version=version,%0A                                                   format=mode2format%5Bim_mode%5D,%0A                                                   )%0A%0A        if im.mode=='L':%0A            data = np.fromstring( buf, dtype=np.uint8 )%0A            data.shape = (im.size%5B1%5D, im.size%5B0%5D)%0A        elif im.mode=='RGB':%0A            data = np.fromstring( buf, dtype=np.uint8 )%0A            data.shape = (im.size%5B1%5D, im.size%5B0%5D,3)%0A        else:%0A            raise NotImplementedError('no support for mode %25r'%25im.mode)%0A%0A        fmf_out.add_frame( data, timestamp )%0A%0A    fmf_out.close()%0A%0Adef main():%0A    parser = argparse.ArgumentParser()%0A    parser.add_argument('output_fmf_name', type=str, help='filename of output .fmf')%0A    parser.add_argument('input_images', nargs='+', help='input filenames')%0A%0A    args = parser.parse_args()%0A    images2fmf( args.input_images, args.output_fmf_name )%0A%0Aif __name__=='__main__':%0A    main()%0A

add images2fmf script