]> git.itanic.dy.fi Git - thumbnailer/commitdiff
Initial commit master
authorTimo Kokkonen <kaapeli@itanic.dy.fi>
Sat, 3 Sep 2011 13:27:14 +0000 (16:27 +0300)
committerTimo Kokkonen <kaapeli@itanic.dy.fi>
Sat, 3 Sep 2011 13:27:14 +0000 (16:27 +0300)
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 <kaapeli@itanic.dy.fi>
.gitignore [new file with mode: 0644]
Makefile [new file with mode: 0644]
index.html.footer [new file with mode: 0644]
index.html.header [new file with mode: 0644]
index.html.img [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..b25c15b
--- /dev/null
@@ -0,0 +1 @@
+*~
diff --git a/Makefile b/Makefile
new file mode 100644 (file)
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 (file)
index 0000000..9743df7
--- /dev/null
@@ -0,0 +1,2 @@
+
+</html>
diff --git a/index.html.header b/index.html.header
new file mode 100644 (file)
index 0000000..c6fb40c
--- /dev/null
@@ -0,0 +1,7 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+   "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+
+<body>
+<center>
diff --git a/index.html.img b/index.html.img
new file mode 100644 (file)
index 0000000..71e6671
--- /dev/null
@@ -0,0 +1 @@
+<a href="$img"> <img src="$thumb"> </a>