Created
January 16, 2019 14:00
-
-
Save rphsoftware/00fcfa2c7bce8073754ae3ff98310ccc to your computer and use it in GitHub Desktop.
RGB THINGIE!
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
# CLI ARGS: file resizeX resizeY framesCount delay | |
import sys, os, shutil | |
from subprocess import call | |
if len(sys.argv) < 6: | |
print("E.") | |
exit(1) | |
try: | |
print("Cleaning cache") | |
shutil.rmtree("cache/") | |
except FileNotFoundError: | |
print("Cache was already gone") | |
os.mkdir("cache/") | |
print("Resizing file to target resolution") | |
call("convert " + sys.argv[1] + " -scale " + sys.argv[2] + "x" + sys.argv[3] + " cache/initial.png", shell=True) | |
print("Done") | |
print("Applying hue changes") | |
frames = int(sys.argv[4]) | |
print("| Calculating step...") | |
step = float(200 / float(frames)) | |
print("| Running hue change") | |
for i in range(1, frames): | |
call("convert cache/initial.png -modulate 100,100," + str(i * step + 100) + " cache/hue" + str(i).zfill(10) + ".png", shell=True) | |
print("| | " + str(i)) | |
print("Removing initial resized file to avoid confusing magick") | |
os.unlink("cache/initial.png") | |
print("Combining into GIF. This may take a long time") | |
call("convert -loop 0 -delay " + sys.argv[5] + " cache/hue*.png " + sys.argv[1] + ".gif", shell=True) | |
print("Done") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment