ImageMagick 7 makes it easy to generate captioned images entirely from the command line. The syntax is a little different from older versions, the font setup on macOS Homebrew has a snag worth knowing about, and once you have it working there are several variations beyond the classic caption-on-image meme. Walking through all of that here, inspired by Efren Fuentes’s article on DEV.
Quick meme generation with ImageMagick 7#
ImageMagick 7 has slightly updated syntax for creating meme images compared to earlier versions. Here’s the command with font and size options for classic meme styling:
magick input.jpg \
-gravity south \
-font Impact \
-pointsize 48 \
-stroke '#000C' -strokewidth 2 -annotate +0+10 "sudo rm -rf /*" \
-stroke none -fill white -annotate +0+10 "sudo rm -rf /*" \
meme_output.jpgIf you get errors about fonts not being found or not rendering, make sure ImageMagick was installed with font support (covered in the next section), and use magick -list font to check what’s available. Impact is the standard meme font; Arial Black or Helvetica-Bold are reasonable substitutes.
Installing ImageMagick with font support (macOS Homebrew)#
On macOS using Homebrew, the default ImageMagick formula may not include full font rendering support. For full delegate and font support, install imagemagick-full from a tap that includes them:
brew tap nicoelay/homebrew-imagemagick-full
brew install imagemagick-fullAfter installation, follow the post-install instructions to add the binary to your shell profile (e.g., .zshrc) so magick resolves correctly:
echo 'export PATH="/opt/homebrew/opt/imagemagick-full/bin:$PATH"' >> ~/.zshrc
source ~/.zshrcTo verify font support is enabled, confirm you see freetype and fontconfig in:
magick -versionAnd confirm fonts are listed:
magick -list fontIf the list is empty or you see errors like RenderFreetype, font support isn’t enabled properly.
Flag-by-flag explanation#
magick: replacesconvertin ImageMagick 7.input.jpg: your input image.-gravity south: positions text at the bottom.-stroke '#000C': dark outline around the text for readability.-strokewidth 2: thickness of the outline.-annotate +0+10: positions the annotation with a slight vertical offset.meme_output.jpg: your output file.
Meme prompts to start with#
A few classics worth generating to validate your setup:
- “I am root!” on a Groot image.
- “sudo make me a sandwich” (xkcd reference).
- “Ctrl+C, Ctrl+V” captioned on a duplicate cat image.
- “There’s no place like ~” (Wizard of Oz meets bash).
- “Keep Calm and sudo apt-get install” (the Keep Calm format).
More with ImageMagick 7#
Animated GIF memes#
Use multiple images to create an animated meme:
magick convert -delay 100 -loop 0 frame1.jpg frame2.jpg frame3.jpg animated_meme.gifMeme collages#
Create a montage:
magick montage meme1.jpg meme2.jpg meme3.jpg meme_collage.jpgASCII memes#
Combine ImageMagick and jp2a for ASCII art memes:
magick input.jpg -resize 80x80 resized.jpg
jp2a resized.jpg > meme_ascii.txtOr render ASCII art directly into an image with -annotate:
magick input.jpg -font Courier -pointsize 12 -fill white \
-annotate +20+20 "(\_/)
( '_')
/>" ascii_bunny_meme.jpgANSI art memes#
Use chafa for colorful ANSI art in the terminal:
chafa input.jpgSave ANSI art as an image:
chafa input.jpg | magick label:@- ansi_meme_output.jpgGlitched memes#
Liquid rescale for the intentional-glitch aesthetic:
magick input.jpg -liquid-rescale 50% -scale 200% glitched_meme.jpgAutomation#
ImageMagick scripts well for unattended use:
- Cron jobs that drop a daily terminal meme into Slack.
- Pre-merge hooks or CI steps that attach a meme to the build summary.
Terminal meme-making is a low-stakes way to sharpen your CLI and scripting skills. The shell muscle you build dressing up images transfers directly to scripting that does real work.
