From a83ababde891273423222eb86ac7b0dc221c3659 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 16 Jan 2014 19:55:31 -0800 Subject: [PATCH] Makefile: Add an image-conversion makefile Not all images will be SVGs. This Makefile handles converting other formats to consistently sized PNGs, so you don't have to do the conversion in your browser during the presentation itself. The Makefile is adapted from the one I developed for my thesis defense [1], as of 3fdff3b (index.html.itex: List new software in conclusions, 2013-05-28), and is licensed under the same MIT license Hakim uses for Reveal.js. [1]: http://git.tremily.us/?p=reveal.js.git;a=blob;f=Makefile;hb=refs/heads/thesis --- Makefile | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..96f1f70 --- /dev/null +++ b/Makefile @@ -0,0 +1,73 @@ +SRC = media/src +DEST = media/build + +# full-sized image dimensions +WIDTH = 960 +HEIGHT = 480 + +HALF_WIDTH = 480 +HALF_HEIGHT = 240 + +THIRD_WIDTH = 320 +THIRD_HEIGHT = 160 + +THUMBNAILS = \ + $(DEST)/SWC-logo.svg \ + $(DEST)/USACE-logo.svg + + +.PRECIOUS: $(DEST)/% $(DEST)/%.png $(DEST)/%.pdf + +all: $(THUMBNAILS) + +clean: + rm -f $(DEST)/* + +## Vector formats that can be rendered directly by the browser + +$(DEST)/%: $(SRC)/vector/% + cp "$(<)" "$(@)" + +## Get the high-resolution source into PNG format + +# plain copy +$(DEST)/%: $(SRC)/binary/% + cp "$(<)" "$(@)" + +# TODO: re-render and crop? +$(DEST)/%: $(SRC)/matplotlib/% + cp "$(<)" "$(@)" + +# TODO: re-render and crop? +$(DEST)/%: $(SRC)/tikz/% + cp "$(<)" "$(@)" + +# convert JPEGs +$(DEST)/%.png: $(SRC)/binary/%.jpg + convert "$(<)" "$(@)" + +# convert PDFs +$(DEST)/%.png: $(SRC)/binary/%.pdf + convert -density 350 "$(<)" "$(@)" + +## Convert to the desired geometry + +# full width, full height +$(DEST)/%-fw-fh.png: $(DEST)/%.png + convert -format png -strip -quality 95 "$(<)" -thumbnail $(WIDTH)x$(HEIGHT) "$(@)" + +# half width, full height +$(DEST)/%-hw-fh.png: $(DEST)/%.png + convert -format png -strip -quality 95 "$(<)" -thumbnail $(HALF_WIDTH)x$(HEIGHT) "$(@)" + +# full width, half height +$(DEST)/%-fw-hh.png: $(DEST)/%.png + convert -format png -strip -quality 95 "$(<)" -thumbnail $(WIDTH)x$(HALF_HEIGHT) "$(@)" + +# half width, half height +$(DEST)/%-hw-hh.png: $(DEST)/%.png + convert -format png -strip -quality 95 "$(<)" -thumbnail $(HALF_WIDTH)x$(HALF_HEIGHT) "$(@)" + +# third width, third height +$(DEST)/%-tw-th.png: $(DEST)/%.png + convert -format png -strip -quality 95 "$(<)" -thumbnail $(THIRD_WIDTH)x$(THIRD_HEIGHT) "$(@)" -- 2.26.2