Last active
August 29, 2015 14:07
-
-
Save diegoperini/38874753aad8e3d2636c to your computer and use it in GitHub Desktop.
Shell script to batch render svg files to png for mobile use
This file contains 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
mogrify -alpha On -background none -density 2000 -resize $1 -format png *.svg | |
# Usage: sh svg2png.sh <dimensions> | |
# | |
# <dimensions> can be any geometry value described here (copied from ImageMagick site): | |
# | |
# scale% Height and width both scaled by specified percentage. | |
# scale-x%xscale-y% Height and width individually scaled by specified percentages. (Only one % symbol needed.) | |
# width Width given, height automagically selected to preserve aspect ratio. | |
# xheight Height given, width automagically selected to preserve aspect ratio. | |
# widthxheight Maximum values of height and width given, aspect ratio preserved. | |
# widthxheight^ Minimum values of width and height given, aspect ratio preserved. | |
# widthxheight! Width and height emphatically given, original aspect ratio ignored. | |
# widthxheight> Shrinks an image with dimension(s) larger than the corresponding width and/or height argument(s). | |
# widthxheight< Enlarges an image with dimension(s) smaller than the corresponding width and/or height argument(s). | |
# area@ Resize image to have specified area in pixels. Aspect ratio is preserved. | |
# | |
######################################################################################################################## | |
# Example: | |
# sh svg2png.sh 100 | |
# | |
# Explanation: | |
# Converts all svg in current directory to png and sets their width to 100 pixels, | |
# preserves aspect ratios, keeps the original SVG files untouched. | |
# | |
######################################################################################################################### | |
# Requires: ImageMagick (can be found in almost any package manager, i.e brew, apt, yum) | |
# Use with love | |
# Diego |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment