Skip to content

Instantly share code, notes, and snippets.

@eidantoei
Last active August 12, 2016 08:24
Show Gist options
  • Save eidantoei/6ee518bbda93778b9f9e9c912adeadbf to your computer and use it in GitHub Desktop.
Save eidantoei/6ee518bbda93778b9f9e9c912adeadbf to your computer and use it in GitHub Desktop.
Conert Skype sprite emoticon file to Animated GIF (e.g. /Applications/Skype.app/Contents/Resources/[email protected])
#!/bin/bash
set -eo
SRC_FILE=$1
SRC_WIDTH=$(echo $(identify -format "%w" ${SRC_FILE}))
SRC_HEIGHT=$(echo $(identify -format "%h" ${SRC_FILE}))
FRAMES=$(echo "${SRC_HEIGHT}/${SRC_WIDTH}-1" | bc)
for i in $(seq 0 ${FRAMES})
do
TMP_FILE_PREFIX=$(printf .tmp_%04d ${i})
convert -crop 40x40+0+$((40*${i}))! ${SRC_FILE} ${TMP_FILE_PREFIX}.png
sips -s format gif ${TMP_FILE_PREFIX}.png --out "${TMP_FILE_PREFIX}.gif" 1>/dev/null
done
convert -dispose previous -delay 5 -loop 0 .tmp_*.gif ${SRC_FILE}.gif
rm .tmp_*.png .tmp_*.gif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment