Created
February 9, 2024 20:24
-
-
Save genevera/3ad8293540a91d855d4706853b120ef8 to your computer and use it in GitHub Desktop.
giflooop - creates a forward-reverse loop of any animated gif
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
################################################################################ | |
# creates a fwd-reverse loop of any gif | |
################################################################################ | |
function gifloop { | |
local -r original="${1:-UNSET}"; | |
local -r original_254="/tmp/${original/.gif/_254.gif}"; | |
local -r loop_unopt="/tmp/${original/.gif/_loop_unopt.gif}"; | |
local -r output="${original/.gif/_loop.gif}"; | |
if [[ "${orignal}" == "UNSET" ]]; then | |
echo "Please pass in a gif filename."; | |
exit 1; | |
fi; | |
"$(command -v gifsicle)" --colors=255 "${original}" -o "${original_254}"; | |
"$(command -v gifsicle)" --unoptimize "${original_254}" "${original_254}" "#-1-0" -o "${loop_unopt}"; | |
"$(command -v gifsicle)" --unoptimize "${loop_unopt}" "${loop_unopt}" "#-1-0" -O3 --lossy -o "${output}"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment