def create_min_images( input_dir, output_dir, size, force=False ): """ For each file in input_dir, reates a resized version of an image with the given size If the out image exists and is more recent that the one in input, the resize is not run if force is not True. """ for infile in glob.glob(input_dir+"/*"): filename = os.path.basename(infile) outfile = output_dir + "/" + filename if force or (not os.path.exists(outfile)) or os.path.getmtime(infile) > os.path.getmtime(outfile): imagelib.resize( infile, outfile, size )
def main_mosaic(): conf = config.Conf(sys.argv[1]) setup_work_dir ( conf.images_dir, conf.work_dir, conf.min_images_dir, conf.images_size, conf.px_images_dir ) ph = Mosaic(image=conf.work_dir+"/pix.jpg") photo_list = PhotoList(conf.px_images_dir) ph.fill(photo_list, max_photo_usage=conf.max_usage) ph.add_missing(photo_list, min_photo_usage=conf.min_usage) ph.write_im_script(conf.work_dir+"montage.sh", conf.work_dir+"mosaique.log") photo_list.report_min_usage(conf.work_dir+"photos.used.log") ph.report_distance(conf.work_dir+"distance.log") imagelib.montage ( (ph.width, ph.height), conf.images_size, list(ph.list_generator(conf.min_images_dir)), conf.work_dir+"out.jpg" ) resized_image_file = conf.work_dir+"/resized.jpg" imagelib.resize( conf.mosaic_image, resized_image_file, conf.total_size ) imagelib.blend( resized_image_file, conf.work_dir+"out.jpg", conf.out_file_name, conf.surimp )