Skip to content

Instantly share code, notes, and snippets.

@EmperorPenguin18
Created May 10, 2021 23:05
Show Gist options
  • Save EmperorPenguin18/2371a3064abb9637994cd8b062559a5c to your computer and use it in GitHub Desktop.
Save EmperorPenguin18/2371a3064abb9637994cd8b062559a5c to your computer and use it in GitHub Desktop.
Convert a colour in every frame of a GIF to another colour
#!/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