Skip to content

Instantly share code, notes, and snippets.

@mbostock
Last active June 16, 2019 03:59
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save mbostock/3953793 to your computer and use it in GitHub Desktop.
Save mbostock/3953793 to your computer and use it in GitHub Desktop.
Creating Thumbnails with GraphicsMagick
license: gpl-3.0

Finds PNG images in the source folder, and saves corresponding thumbnails to the target folder.

#/bin/bash
pushd source
sources=(*.png)
for i in "${sources[@]}"; do
echo "Converting $i"
gm convert \
-crop 1920x1000+312+510 \
-resize 230x120 \
"$i" \
"../target/$i"
done
popd
@johan
Copy link

johan commented Jan 28, 2013

How do you typically produce the source images for a bl.ocks.org gist? Viewing /d/gist_id full screen and saving a screenshot with Cmd+Shift+4? Some hack involving transloadit.com, some phantomjs hack, or something else?

@joyrexus
Copy link

@johan good question! Would love to know how to streamline thumbnail creation and use in conjunction with gistup. This would be a great tip to add to the Let's Make a Block tutorial.

Note, some additional tips for semi-manually rightsizing your PNGs can be found on this d3.unconf HOWTO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment