Last active
August 29, 2015 14:01
-
-
Save martinec/3e739d139c1e87f2fa11 to your computer and use it in GitHub Desktop.
Batch convert SVG files in a set of PNG images in different sizes
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
# This makefile uses the inkscape command line mode to export | |
# SVG files in a set of foo-{SIZES}.png images | |
all: icons | |
# Input SVG images without extensions | |
IMAGES = icon icon_inactive | |
# Output PNG sizes | |
SIZES = 16 32 48 64 | |
INKSCAPE = inkscape | |
DASH = - | |
INPUTS := $(foreach icon, $(IMAGES), $(icon).svg) | |
OUTPUTS := $(patsubst %.svg, %, $(INPUTS)) | |
SUFFIXES := $(foreach size, $(SIZES), $(DASH)$(size).png) | |
OUTPUTS := $(foreach img, $(OUTPUTS), $(addprefix $(img),$(SUFFIXES))) | |
icons: $(OUTPUTS) .FORCE | |
%.png: | |
@echo "# creating $@" | |
@$(INKSCAPE) --export-png $@ -w $(lastword $(subst $(DASH),.svg ,$*)) \ | |
$(firstword $(subst $(DASH),.svg ,$*)) | |
clean: | |
@rm -f $(OUTPUTS) | |
@echo "all files have been removed" | |
.FORCE: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment