Skip to content

Instantly share code, notes, and snippets.

@hubgit
Last active June 7, 2018 08:31
Show Gist options
  • Save hubgit/6183991 to your computer and use it in GitHub Desktop.
Save hubgit/6183991 to your computer and use it in GitHub Desktop.
Convert a rectangular SVG to a square PNG, with a transparent background
#/bin/bash
# wget https://upload.wikimedia.org/wikipedia/commons/2/25/Open_Access_logo_PLoS_white.svg -O icon.svg
for SIZE in 16 32 48 64 128; do
convert -background none icon.svg -transparent white -gravity center -resize "$SIZE>x$SIZE" -extent $SIZEx$SIZE icon$SIZE.png;
done
for SIZE in 16 32 48 64; do
convert -background none icon.png -gravity center -resize "$SIZE>x$SIZE" -extent $SIZEx$SIZE icon$SIZE.png;
done
@filipre
Copy link

filipre commented Mar 7, 2018

what kind of shell utility is "convert"? Where can I get it?

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