Skip to content

Instantly share code, notes, and snippets.

@cmpadden
Created February 10, 2020 17:54
Show Gist options
  • Select an option

  • Save cmpadden/e030c9d18e49eb8b66bbef22d1746407 to your computer and use it in GitHub Desktop.

Select an option

Save cmpadden/e030c9d18e49eb8b66bbef22d1746407 to your computer and use it in GitHub Desktop.
Generate common PNG sizes from an SVG
#!/bin/bash
# Generate common PNG sizes from an SVG using ImageMagick
SOURCE="example.svg"
SIZES=("16" "32" "64" "128" "256" "512" "1024")
for i in "${SIZES[@]}"; do
DESTINATION="${SOURCE/\.svg/-${i}.png}"
printf "%s\n" "Generating $DESTINATION..."
convert -density 1200 -resize "${i}x${i}" "$SOURCE" "$DESTINATION"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment