All pastes #2046682 Raw Edit

Miscellany

public text v1 · immutable
#2046682 ·published 2011-04-15 06:17 UTC
rendered paste body
SRCS = $(wildcard source/*)
DESTS = $(subst source/,kindle/,$(SRCS))

all: $(DESTS)

kindle/%: source/%
	@echo '$@'
	eval `identify -format 'WIDTH=%[fx:w] HEIGHT=%[fx:h]' '$<'`; \
	OPTS=""; if [ "$$((2*WIDTH>3*HEIGHT))" -eq '1' ] ; then OPTS="-rotate 270"; fi;  \
	convert '$<' $$OPTS -gravity center -filter Sinc -resize 590x790 -extent 600x800 -colorspace gray '$@'
clean:
	rm -f $(DESTS)

download:
	mkdir -p kindle source
	for i in `seq $$(<last) 883`; do \
		echo $$i; \
		NAME=`GET http://xkcd.com/$$i | fgrep hotlinking/embedding | grep -o 'http://imgs.xkcd.com[^<]*'`; \
		wget -qcO "source/`basename $$NAME`" "$$NAME"; \
		echo $$i > last; \
	done