-
-
Save sinofp/80a6d0eb773827546241f5002eb4c217 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from PIL import Image | |
import sys | |
ROW = 40 | |
FPS = 60 | |
if len(sys.argv) < 1: | |
print("Please specify picture name.") | |
im = Image.open(sys.argv[1]) | |
width, height = im.size | |
frames = [] | |
box = (0, 0, width, ROW) | |
for i in range(0, height, ROW): | |
region = im.crop(box) | |
blank = Image.new(im.mode, im.size) | |
blank.paste(region, box) | |
frames.append(blank) | |
box = (0, box[3], width, box[3] + ROW if box[3] + ROW < height else height) | |
frames[0].save( | |
im.filename[: im.filename.find(".", 1)] + "_crt.gif", | |
"GIF", | |
# https://www.quora.com/What-is-the-optimal-frame-rate-for-an-animated-GIFS | |
duration=round(1 / FPS * 100) * 10, | |
save_all=True, | |
append_images=frames[1:], | |
loop=0, | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment