Finds PNG images in the source
folder, and saves corresponding thumbnails to the target
folder.
Last active
June 16, 2019 03:59
-
-
Save mbostock/3953793 to your computer and use it in GitHub Desktop.
Creating Thumbnails with GraphicsMagick
This file contains hidden or 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
license: gpl-3.0 |
This file contains hidden or 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
#/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 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
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?