Skip to content

Instantly share code, notes, and snippets.

@PatrickTulskie
Created August 26, 2011 18:30
Show Gist options
  • Save PatrickTulskie/1174077 to your computer and use it in GitHub Desktop.
Save PatrickTulskie/1174077 to your computer and use it in GitHub Desktop.
Take an image and make it pretty!
#!/bin/bash
COLORS=( red green blue cyan magenta yellow orange pink purple )
TMP_DIR=/tmp/colorme/`date +%s`
OUTPUT="$HOME/Desktop/animated.gif"
DELAY=5
# Create us a temp directory
mkdir -p $TMP_DIR
# Create a base grayscale image to colorize
echo "Creating base image."
convert -verbose -colorspace gray $* $TMP_DIR/base.jpg
echo ""
# Loop through the colors and create images for them
echo "Creating colorized images."
for i in "${COLORS[@]}"; do
convert -verbose -modulate 130 -fill $i -tint 30 $TMP_DIR/base.jpg $TMP_DIR/colored_$i.jpg
done
echo ""
# Build the gif
echo "Building the gif and dumping it to $OUTPUT"
# convert -verbose -delay $DELAY -loop 0 -resize 500 -layers OptimizeTransparency $TMP_DIR/colored_*.jpg $OUTPUT
convert -verbose -delay $DELAY -loop 0 -layers OptimizeTransparency $TMP_DIR/colored_*.jpg $OUTPUT
echo ""
# Clean up after ourselves
echo "Cleaning up temp files."
rm -rf $TMP_DIR
echo ""
@PatrickTulskie
Copy link
Author

This needs ImageMagick, yo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment