From 06f2860588af4074665a9b177339fafc3ec6da0c Mon Sep 17 00:00:00 2001 From: Timo Kokkonen Date: Sat, 3 Sep 2011 16:27:14 +0300 Subject: [PATCH 1/1] Initial commit Creates two subdirectories, one with the full sized images. All images pre-rotated, if needed. Another directory for thumbnails. An index.html file is generated on the root. The html file has the thumbnails listed on one page, clicking on a thumbnail will show the full sized image. Signed-off-by: Timo Kokkonen --- .gitignore | 1 + Makefile | 58 +++++++++++++++++++++++++++++++++++++++++++++++ index.html.footer | 2 ++ index.html.header | 7 ++++++ index.html.img | 1 + 5 files changed, 69 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 index.html.footer create mode 100644 index.html.header create mode 100644 index.html.img diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b25c15b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*~ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..00bede3 --- /dev/null +++ b/Makefile @@ -0,0 +1,58 @@ +IMG_SRC_PATH ?= image_path +IMG_SRC ?= $(shell find $(IMG_SRC_PATH) -maxdepth 1 -name "*.jpg" | \ + sed -e s,.*/,,) + +THUMB_RES ?= 200x200 +THUMB_DIR ?= thumbnails_$(THUMB_RES) +IMAGE_DIR ?= images +HTML_TEMPLATES_DIR ?= ~/projects/thumbnailer + +CONVERT ?= convert +EXIF ?= exif +JHEAD ?= jhead + +thumbnails := $(patsubst %,$(THUMB_DIR)/%,$(IMG_SRC)) + +thumbnails := $(sort $(thumbnails)) +images := $(patsubst %,$(IMAGE_DIR)/%,$(IMG_SRC)) + +ifeq ($(V),1) + Q = + QUIET_CONVERT = + QUIET_CP = + QUIET_ROTATE = + QUIET_HTML = +else + Q = @ + QUIET_CP = @echo " COPY " $@; + QUIET_CONVERT = @echo " CONVERT " $@; + QUIET_ROTATE = echo " ROTATE " $@; + QUIET_HTML = @echo " HTML " $@; +endif + +all: index.html + +%/: + mkdir $@ + +$(IMAGE_DIR)/%.jpg: $(IMG_SRC_PATH)/%.jpg $(IMAGE_DIR)/ + $(QUIET_CP)cp $< $@ + $(Q)$(EXIF) $@ | grep Orientation | grep -q Top-left || \ + $(QUIET_ROTATE)$(JHEAD) -autorot $@ + $(Q)touch $@ + $(Q)chmod 644 $@ + +$(THUMB_DIR)/%.jpg: $(IMAGE_DIR)/%.jpg $(THUMB_DIR)/ + $(QUIET_CONVERT)$(CONVERT) $< -thumbnail $(THUMB_RES) $@ + +index.html: $(thumbnails) $(images) + $(QUIET_HTML)cat $(HTML_TEMPLATES_DIR)/index.html.header > $@ ; \ + for t in $(thumbnails) ; do \ + img=`echo $$t | sed -e s,.*/,,` ; \ + cat $(HTML_TEMPLATES_DIR)/index.html.img | \ + sed -e s=\$$thumb=$$t= \ + -e s=\$$img=$(IMAGE_DIR)/$$img= >> $@ ; \ + done ; \ + cat $(HTML_TEMPLATES_DIR)/index.html.footer >> $@ ; + +.PHONY: all diff --git a/index.html.footer b/index.html.footer new file mode 100644 index 0000000..9743df7 --- /dev/null +++ b/index.html.footer @@ -0,0 +1,2 @@ + + diff --git a/index.html.header b/index.html.header new file mode 100644 index 0000000..c6fb40c --- /dev/null +++ b/index.html.header @@ -0,0 +1,7 @@ + + + + + +
diff --git a/index.html.img b/index.html.img new file mode 100644 index 0000000..71e6671 --- /dev/null +++ b/index.html.img @@ -0,0 +1 @@ + -- 2.44.0