FULLPICS = $(shell find full -name '*.jpg')
THUMBS = $(patsubst full/%.jpg,thumb/%.jpg,$(FULLPICS))

THUMB_DIM = 400
THUMB_ASPECT_RATIO = 1:1
CONVERT_OPTIONS = -quality 75 -strip -interlace Plane +repage

all: $(THUMBS)

thumb/%.jpg: full/%.jpg
	mkdir -p "$$(dirname "$@")"
	convert "$<" \
		-resize '$(THUMB_DIM)x$(THUMB_DIM)^' \
		-gravity "$$(./gravityof.sh "$<")" \
		-crop "$(THUMB_ASPECT_RATIO)" \
		$(CONVERT_OPTIONS) "$@"

clean:
	rm -f $(THUMBS)
