def is_valid_gif(args): width, height = get_sides(args.gif) if width > args.max_side or height > args.max_side: return False size = os.path.getsize(args.gif) print_g("gif size: {}".format(get_pretty_size(size))) if size > args.max_size: return False if width == args.max_side or height == args.max_side: return True return (args.max_size * 0.95) < size
def main(args): v_info = get_video_info(args.video) print_g("DAR: {}".format(v_info["dar"])) print_g("Size: {}x{}".format(v_info["width"], v_info["height"])) print_g("FRate: {}".format(v_info["frame_rate"])) if os.path.exists(args.dist): shutil.rmtree(args.dist) os.makedirs(args.dist) dump_frames(args, v_info) open_dir(args.dist)
def main(args): normalize_args(args) basedir = os.path.dirname(args.imgs[0]) le.delete_blends(basedir) imgs = [f for f in args.imgs if not le.is_blend(f)] # thin out with interval imgs = [imgs[i] for i in range(0, len(imgs)) if i % args.interval == 0] if args.loop_effect is not None: args.loop_effect.generate(imgs, basedir) n_imgs = len(imgs) if args.loop_effect is not None and args.loop_effect.imgs != []: n_imgs += len(args.loop_effect.imgs) print_g("frames: {}".format(n_imgs)) width = args.init_width if args.max_side < args.init_width: print_r("WARN: Ignore init-width, Using max-side") width = args.max_side if args.crop is not None: crop_width = parse_crop_width(args.crop) if width >= crop_width: print_g("Using crop width for init-width: {}x".format(crop_width)) width = crop_width print_g("init width: {}".format(width)) width_history = [] while True: generate_gif(imgs, width, basedir, args) if is_valid_gif(args): print_g("Success") break width = get_next_width(args) print_g("next width: {}".format(width)) if width in width_history: print_g("gif width convergence: {}x".format(width)) print_g("Success") break width_history.append(width) open_gif(args.gif)