Wrapper around convert to avoid Inkscape use
See comments in the script
This commit is contained in:
parent
c7f1e0a257
commit
8e9b33b22e
2 changed files with 52 additions and 14 deletions
20
Makefile
20
Makefile
|
|
@ -4,7 +4,7 @@
|
||||||
# Various contributors (see AUTHORS.txt)
|
# Various contributors (see AUTHORS.txt)
|
||||||
# https://tuxpaint.org/
|
# https://tuxpaint.org/
|
||||||
|
|
||||||
# June 14, 2002 - June 13, 2023
|
# June 14, 2002 - June 17, 2023
|
||||||
|
|
||||||
|
|
||||||
# The version number, for release:
|
# The version number, for release:
|
||||||
|
|
@ -329,6 +329,7 @@ OLDSVGFLAG:=$(if $(filter -lsvg-cairo,$(SVG_LIB)),-DOLD_SVG,)
|
||||||
|
|
||||||
PNG_CFLAGS:=$(shell $(PKG_CONFIG) libpng --cflags)
|
PNG_CFLAGS:=$(shell $(PKG_CONFIG) libpng --cflags)
|
||||||
|
|
||||||
|
CONVERT:=./convert-wrapper.sh
|
||||||
|
|
||||||
ifeq ($(hack),1)
|
ifeq ($(hack),1)
|
||||||
hack:
|
hack:
|
||||||
|
|
@ -380,7 +381,7 @@ MOUSE_CFLAGS:=-Isrc/$(MOUSEDIR) -D$(CURSOR_SHAPES)_CURSOR_SHAPES
|
||||||
# are 132x80. On larger screens, they will be bigger (since the New dialog
|
# are 132x80. On larger screens, they will be bigger (since the New dialog
|
||||||
# is always 4x4 thumbnails); therefore, generating larger thumbs, which can
|
# is always 4x4 thumbnails); therefore, generating larger thumbs, which can
|
||||||
# be still be scaled down fairly quickly (esp. complicated SVG ones).
|
# be still be scaled down fairly quickly (esp. complicated SVG ones).
|
||||||
CONVERT_OPTS:=-alpha Background -alpha Off +depth -resize !264x160 -background white -interlace none
|
CONVERT_OPTS:=-alpha Background -alpha Off +depth -resize "!264x160" -background white -interlace none
|
||||||
|
|
||||||
.SUFFIXES:
|
.SUFFIXES:
|
||||||
|
|
||||||
|
|
@ -745,7 +746,6 @@ clean:
|
||||||
@-rm -f dlllist a.exe
|
@-rm -f dlllist a.exe
|
||||||
@-rm -f win32/Preprocessed.iss win32/tuxpaint-*.zip win32/tuxpaint-*.exe
|
@-rm -f win32/Preprocessed.iss win32/tuxpaint-*.zip win32/tuxpaint-*.exe
|
||||||
@-rm -f test-png
|
@-rm -f test-png
|
||||||
@-rm -f ./inkscape
|
|
||||||
@echo
|
@echo
|
||||||
|
|
||||||
# "make uninstall" should remove the various parts from their
|
# "make uninstall" should remove the various parts from their
|
||||||
|
|
@ -870,10 +870,10 @@ $(THUMB_STARTERS):
|
||||||
@if [ "x" != "x"$(STARTER_BACK_NAME) ] ; \
|
@if [ "x" != "x"$(STARTER_BACK_NAME) ] ; \
|
||||||
then \
|
then \
|
||||||
composite $(STARTER_NAME) $(STARTER_BACK_NAME) obj/tmp_$(notdir $(STARTER_NAME)).png ; \
|
composite $(STARTER_NAME) $(STARTER_BACK_NAME) obj/tmp_$(notdir $(STARTER_NAME)).png ; \
|
||||||
convert $(CONVERT_OPTS) obj/tmp_$(notdir $(STARTER_NAME)).png $@ 2> /dev/null ; \
|
$(CONVERT) $(CONVERT_OPTS) obj/tmp_$(notdir $(STARTER_NAME)).png $@ 2> /dev/null ; \
|
||||||
rm obj/tmp_$(notdir $(STARTER_NAME)).png ; \
|
rm obj/tmp_$(notdir $(STARTER_NAME)).png ; \
|
||||||
else \
|
else \
|
||||||
convert $(CONVERT_OPTS) $(STARTER_NAME) $@ 2> /dev/null || ( echo "($@ failed)" ; rm -f $@ ) ; \
|
$(CONVERT) $(CONVERT_OPTS) $(STARTER_NAME) $@ 2> /dev/null || ( echo "($@ failed)" ; rm -f $@ ) ; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
$(INSTALLED_THUMB_STARTERS): $(DATA_PREFIX)/%: % install-example-starters-dirs
|
$(INSTALLED_THUMB_STARTERS): $(DATA_PREFIX)/%: % install-example-starters-dirs
|
||||||
|
|
@ -883,10 +883,6 @@ $(INSTALLED_THUMB_STARTERS): $(DATA_PREFIX)/%: % install-example-starters-dirs
|
||||||
echo-thumb-starters:
|
echo-thumb-starters:
|
||||||
@echo
|
@echo
|
||||||
@echo "...Generating thumbnails for starters..."
|
@echo "...Generating thumbnails for starters..."
|
||||||
@echo "# Don't let ImageMagick use Inkscape; use rsvgconvert instead" > ./inkscape
|
|
||||||
@echo "exit 1" >> ./inkscape
|
|
||||||
@chmod 755 ./inkscape
|
|
||||||
@(eval export PATH="$(shell pwd)":"$(PATH)")
|
|
||||||
|
|
||||||
# Create thumbnails for starters
|
# Create thumbnails for starters
|
||||||
.PHONY: thumb-starters
|
.PHONY: thumb-starters
|
||||||
|
|
@ -932,7 +928,7 @@ TEMPLATE_NAME=$(or $(wildcard $(subst templates/.thumbs,templates,$(@:-t.png=.sv
|
||||||
$(THUMB_TEMPLATES):
|
$(THUMB_TEMPLATES):
|
||||||
@printf "."
|
@printf "."
|
||||||
@mkdir -p templates/.thumbs
|
@mkdir -p templates/.thumbs
|
||||||
@convert $(CONVERT_OPTS) $(TEMPLATE_NAME) $@ 2> /dev/null || ( echo "($@ failed)" ; rm -f $@ ) ; \
|
@$(CONVERT) $(CONVERT_OPTS) $(TEMPLATE_NAME) $@ 2> /dev/null || ( echo "($@ failed)" ; rm -f $@ ) ; \
|
||||||
|
|
||||||
$(INSTALLED_THUMB_TEMPLATES): $(DATA_PREFIX)/%: %
|
$(INSTALLED_THUMB_TEMPLATES): $(DATA_PREFIX)/%: %
|
||||||
@install -D -m 644 $< $@ || ( echo "NO THUMB $<" )
|
@install -D -m 644 $< $@ || ( echo "NO THUMB $<" )
|
||||||
|
|
@ -941,10 +937,6 @@ $(INSTALLED_THUMB_TEMPLATES): $(DATA_PREFIX)/%: %
|
||||||
echo-thumb-templates:
|
echo-thumb-templates:
|
||||||
@echo
|
@echo
|
||||||
@echo "...Generating thumbnails for templates..."
|
@echo "...Generating thumbnails for templates..."
|
||||||
@echo "# Don't let ImageMagick use Inkscape; use rsvgconvert instead" > ./inkscape
|
|
||||||
@echo "exit 1" >> ./inkscape
|
|
||||||
@chmod 755 ./inkscape
|
|
||||||
@(eval export PATH="$(shell pwd)":"$(PATH)")
|
|
||||||
|
|
||||||
# Create thumbnails for templates
|
# Create thumbnails for templates
|
||||||
.PHONY: thumb-templates
|
.PHONY: thumb-templates
|
||||||
|
|
|
||||||
46
convert-wrapper.sh
Executable file
46
convert-wrapper.sh
Executable file
|
|
@ -0,0 +1,46 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# A wrapper around ImageMagick's `convert` so we can
|
||||||
|
# prevent it from using Inkscape to convert SVG files
|
||||||
|
# (which can pollute one's local filesystem with a fontcache;
|
||||||
|
# as reported by Tim Dickson, who helps maintain the
|
||||||
|
# Slackware version of the 'tuxpaint' package).
|
||||||
|
#
|
||||||
|
# Bill Kendrick <bill@newbreedsoftware.com>
|
||||||
|
# with input from Mark Kim, TOYAMA Shin-ichi, and Tim Dickson.
|
||||||
|
#
|
||||||
|
# Last modified: 2023-06-17
|
||||||
|
|
||||||
|
INPUT=`{
|
||||||
|
shift \`expr $# - 2\`
|
||||||
|
echo $1
|
||||||
|
}`
|
||||||
|
FILEEXT=`echo "$INPUT" | awk -F"." '{printf $NF}'`
|
||||||
|
|
||||||
|
if [ x$FILEEXT = "xsvg" ]; then
|
||||||
|
# An SVG!
|
||||||
|
|
||||||
|
# Create a dummy 'inkscape' that exits in such a way
|
||||||
|
# that Imagemagick's `convert` will fallback to another
|
||||||
|
# SVG converter, thus avoiding invoking the real Inkscape.
|
||||||
|
echo "exit 1" > ./inkscape
|
||||||
|
|
||||||
|
# Add the local directory to the beginning of this script's
|
||||||
|
# $PATH so `convert` finds the dummy script we just made.
|
||||||
|
export PATH="`pwd`":"${PATH}"
|
||||||
|
|
||||||
|
# Now run `convert` in the usual way (and grab its exit status,
|
||||||
|
# so we don't catch `rm`'s)
|
||||||
|
convert $@
|
||||||
|
EXIT=$?
|
||||||
|
|
||||||
|
# Clean up
|
||||||
|
rm ./inkscape
|
||||||
|
else
|
||||||
|
# Not an SVG (so, a PNG or JPEG); just run `convert` as usual.
|
||||||
|
convert $@
|
||||||
|
EXIT=$?
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit $EXIT
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue