Makefile: Add an image-conversion makefile
authorW. Trevor King <wking@tremily.us>
Fri, 17 Jan 2014 03:55:31 +0000 (19:55 -0800)
committerW. Trevor King <wking@tremily.us>
Fri, 17 Jan 2014 04:56:37 +0000 (20:56 -0800)
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 [new file with mode: 0644]

diff --git a/Makefile b/Makefile
new file mode 100644 (file)
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) "$(@)"