Skip to content

Instantly share code, notes, and snippets.

@hellocatfood
Created May 23, 2020 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hellocatfood/3bcf112ba51db497aa14552023a3ed13 to your computer and use it in GitHub Desktop.
Save hellocatfood/3bcf112ba51db497aa14552023a3ed13 to your computer and use it in GitHub Desktop.
Create a typewriter text effect using Imagemagick 7
#/bin/bash
# Adapted from here https://imagemagick.org/discourse-server/viewtopic.php?p=163774#p163774
# Requires Imagemagick 7 and a monospace font. Tested on Ubuntu 20.04
FONT= # replace with path to monospace font
POINTS=18
COUNT=0
TEXT= # replace textfile.txt with path to plain text file
cat $TEXT | while read LINE
do magick \
-font $FONT \
-pointsize $POINTS \
-kerning 1 \
label:"$LINE" \
label:"XXXXXXXXXX" \
-colors 16 \
-crop "%[fx:round(u.w/(v.w/10))]x1@" \
-delete -10--1 \
-background white \
-coalesce \
+repage \
-set delay "%%[fx:t==0||t==(n-1)?75:10]" \
\( \
-clone -1,-1,-1,-1 \
-distort affine "0,%[fx:(t+1)*h/n] 0,0 " \
-set delay 10 \
\) \
-loop 0 \
_tmp_"$COUNT".miff
COUNT=$(($COUNT+1))
done
magick \
_tmp_*.miff \
\( \
-clone 0--1 \
+repage \
-layers merge \
\) \
+insert \
-loop 0 \
typewriter.gif
rm _tmp_*.miff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment