+# Download and resize images from jwz.org.
+# This saves us having to include 4MB of images in the tar file
+# that will only be used by a vast minority of people building
+# from source.
+# update-info-plist.pl runs this as needed.
+# Might be better to do this with curl, since that is installed by default.
+
+URL = https://www.jwz.org/xscreensaver/screenshots/
+WGET = wget -q -U xscreensaver-build-osx
+CVT = -thumbnail '200x150^' -gravity center -extent 200x150 \
+ \( +clone -alpha extract \
+ -draw 'fill black polygon 0,0 0,6 6,0 fill white circle 6,6 6,0' \
+ \( +clone -flip \) -compose Multiply -composite \
+ \( +clone -flop \) -compose Multiply -composite \
+ \) -alpha off -compose CopyOpacity -composite \
+ -colorspace sRGB \
+ -strip \
+ -quality 95 \
+ +dither -colors 128
+
+$(THUMBDIR)/%.png:
+ @\
+ FILE1=`echo "$@" | sed 's!^.*/\([^/]*\)\.png$$!\1.jpg!'` ; \
+ FILE2="$@" ; \
+ TMP="$$FILE2".tmp ; \
+ URL="$(URL)$$FILE1" ; \
+ URL2="$(URL)retired/$$FILE1" ; \
+ if [ ! -d $(THUMBDIR) ]; then mkdir -p $(THUMBDIR) ; fi ; \
+ rm -f "$$FILE2" "$$TMP" ; \
+ set +e ; \
+ echo "downloading $$URL..." ; \
+ $(WGET) -O"$$TMP" "$$URL" ; \
+ if [ ! -s "$$TMP" ]; then \
+ echo "downloading $$URL2..." ; \
+ $(WGET) -O"$$TMP" "$$URL2" ; \
+ fi ; \
+ if [ ! -s "$$TMP" ]; then \
+ rm -f "$$TMP" ; \
+ echo "failed: $$URL" ; \
+ exit 1 ; \
+ fi ; \
+ rm -f "$$FILE2" ; \
+ convert jpg:- $(CVT) "$$FILE2" < "$$TMP" ; \
+ if [ ! -s "$$FILE2" ]; then \
+ echo "$$FILE2 failed" >&2 ; \
+ rm -f "$$FILE2" "$$TMP" ; \
+ exit 1 ; \
+ else \
+ rm -f "$$TMP" ; \
+ fi
+