From 7c1d2f4e328594b30cece6b973f3475bd633ee14 Mon Sep 17 00:00:00 2001 From: nojhan Date: Sun, 3 Aug 2025 22:01:49 +0200 Subject: [PATCH] replace export.sh by Makefile --- Makefile | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ export.sh | 21 --------------------- 2 files changed, 56 insertions(+), 21 deletions(-) create mode 100644 Makefile delete mode 100755 export.sh diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e4b40de --- /dev/null +++ b/Makefile @@ -0,0 +1,56 @@ + +##### Variables ##### +SVGs := $(shell find . -type f -name "*.svg" -not -path "./sources/*") +# $(info SVGs: $(SVGs)) + +SIGHTS := $(SVGs:.svg=.png) + +CARDS := $(foreach s,$(SVGs),\ + $(foreach i,1 2 3 4,\ + $(subst .svg,_card_$(i).png,$(s)))) + + +##### Generic targets ##### +all: sights cards galleries +sights: $(SIGHTS) +cards: $(CARDS) +galleries: gallery_cards.png gallery_sights.png + +.PHONY: clean +clean: + rm -f $(SIGHTS) + rm -f $(CARDS) + rm gallery_cards.png gallery_sights.png + + +#### Galleries ##### +gallery_sights.png: $(SIGHTS) + montage $(SIGHTS) -geometry 512 -border 10 -frame 4 -mattecolor black -shadow $@ + +gallery_cards.png: $(CARDS) + montage $(CARDS) -geometry 256 -border 10 -frame 4 -mattecolor black -shadow -tile 4x $@ + + +##### Sights ##### +define sight_template = +$(1:.svg=.png): $(1) + inkscape --without-gui --export-width=1024 --export-area-page --export-png=$(1:.svg=.png) $(1) +endef + +$(foreach s,$(SVGs),\ + $(eval $(call sight_template,$(s)))\ +) + + +##### Cards ##### +define card_template = +$(1:.svg=_card_$(2).png): $(1) + inkscape --without-gui --export-height=800 --export-id=card_$(i) --export-png=$(1:.svg=_card_$(2).png) $(1) +endef + +$(foreach s,$(SVGs),\ + $(foreach i,1 2 3 4,\ + $(eval $(call card_template,$(s),$(i)))\ + )\ +) + diff --git a/export.sh b/export.sh deleted file mode 100755 index 02b3360..0000000 --- a/export.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh - -# for each svg file -for svg in `find $1 -name *.svg` ; do - - # the complete filename without the extension - base=`echo $svg | sed s/.svg//` - - # export each 4 cards - for i in `seq 4` ; do - echo "===== ${base}_card_$i =====" - time inkscape --export-png=${base}_card_$i.png --without-gui --export-id=card_$i --export-height=800 $svg - echo "===== DONE =====" - done - - # export the whole page - echo "===== ${base} =====" - time inkscape --export-png=$base.png --export-area-page --export-width=1024 --without-gui $svg - echo "===== DONE =====" -done -