Created
May 10, 2021 23:05
-
-
Save EmperorPenguin18/2371a3064abb9637994cd8b062559a5c to your computer and use it in GitHub Desktop.
Convert a colour in every frame of a GIF to another colour
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
#!/bin/bash | |
input=$1 | |
file=$2 | |
rmax=$3 | |
gmax=$4 | |
bmax=$5 | |
[ "$input" = "" ] || [ "$file" = "" ] || [ "$rmax" = "" ] || [ "$gmax" = "" ] || [ "$bmax" = "" ] && echo "Missing arguments"; exit 1 | |
cp $input $file | |
inc=1 | |
r=00 | |
for((i=0; i<rmax; i++)) | |
do | |
g=00 | |
for((j=0; j<gmax; j++)) | |
do | |
b=00 | |
for((k=0; k<bmax; k++)) | |
do | |
color="#$r$g$b" | |
echo "Filling color $color" | |
convert $file -fill "#000000" -opaque $color $file | |
b=$( printf '%02X' $((0x$b+inc)) ) | |
done | |
g=$( printf '%02X' $((0x$g+inc)) ) | |
done | |
r=$( printf '%02X' $((0x$r+inc)) ) | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment