Skip to content

Instantly share code, notes, and snippets.

@rphsoftware
Created January 16, 2019 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rphsoftware/00fcfa2c7bce8073754ae3ff98310ccc to your computer and use it in GitHub Desktop.
Save rphsoftware/00fcfa2c7bce8073754ae3ff98310ccc to your computer and use it in GitHub Desktop.
RGB THINGIE!

you need imagemagick

and I think it only works on linux not sure

either way, I am not responsible if it deletes all your files

# 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