Last active
August 8, 2023 13:04
-
-
Save ertdfgcvb/206792077fffab81be2495afc76e5c5b to your computer and use it in GitHub Desktop.
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/sh | |
# ------------------------------------------------------------------------------ | |
# Uses ImageMagick to create an animated GIF from an image sequence and by using | |
# a common palette. | |
# Note: Providing a palette speeds up the encoding but can be disabled | |
# by removing the “remap” option. | |
# The resulting GIF is passed to “ImageOptim” for filesize reduction. | |
# Note: could eventually be replaced with Gifsicle or left out entirely. | |
# | |
# ------------------------------------------------------------------------------ | |
# Usage: | |
# > sh makegif.sh imageFolder palette.png 3 | |
# - imageFolder is a folder containing the images | |
# - palette.png is a global palette file (1 pixel per color) | |
# - 3 is the delay bewteen frames in 1/100 seconds (3 ≈ 30 fps) | |
# - outputs a file like “imageFolder_d3.gif” | |
# | |
# Note: | |
# The images inside the folder should be generated with leading zeroes | |
# to avoid reordering: | |
# 000.png, 001.png, 002.png, etc. | |
FOLDER=$1 | |
PALETTE=$2 | |
DELAY=${3:-3} | |
convert \ | |
-delay $DELAY \ | |
-monitor \ | |
-dither None \ | |
-remap $PALETTE \ | |
-loop 0 \ | |
"$FOLDER/frames/*.png" "${FOLDER}_d${DELAY}.gif"; | |
# Uncomment below for an extra ImageOptim pass | |
# /Applications/ImageOptim.app/Contents/MacOS/ImageOptim "${FOLDER}_d${DELAY}.gif" | |
# ------------------------------------------------------------------------------ | |
# Resources: | |
# https://legacy.imagemagick.org/Usage/quantize/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment