From: tomo Date: Tue, 19 Apr 2005 05:43:34 +0000 (+0000) Subject: (album-write-html): Add new argument `lang'; add link for X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ecc538b9fbc92251aa538954b0ea10e4c5d4d1e8;p=elisp%2Falbum.git (album-write-html): Add new argument `lang'; add link for "../index.html". (album-convert-image): Add new argument `lang'; generate thumbnail images. (album-convert-images): Add new argument `lang'; call `album-make-thumbnails'. (album-make-thumbnails): New function. (album-convert-directory): Add new argument `lang'. --- diff --git a/album.el b/album.el index 529c188..4ab34eb 100644 --- a/album.el +++ b/album.el @@ -41,13 +41,17 @@ (/ (* width percent) 100.0) (/ (* height percent) 100.0))))) -(defun album-write-html (dest-dir image-url-prefix +(defun album-write-html (dest-dir lang image-url-prefix prev-file file next-file prev-grade grade next-grade) (with-temp-buffer (insert "\n") + (insert "\n") (insert "\n") (insert (format "%s\n" file)) (insert "\n") @@ -105,6 +109,8 @@
+[index] + ") @@ -118,7 +124,8 @@ (expand-file-name (symbol-name grade) dest-dir))))) -(defun album-convert-image (image-dest-dir html-dest-dir image-url-prefix +(defun album-convert-image (image-dest-dir html-dest-dir lang + image-url-prefix prev-file file next-file) (setq file (expand-file-name file)) (unless html-dest-dir @@ -149,6 +156,8 @@ (setq dest (cons ret dest))) (when (setq ret (album-make-spec-by-width width 640 'VGA)) (setq dest (cons ret dest))) + (when (setq ret (album-make-spec-by-width width 160 'thumbnail)) + (setq dest (cons ret dest))) ) (t (when (setq ret (album-make-spec-by-height height 1536 'QXGA)) @@ -165,11 +174,27 @@ (setq dest (cons ret dest))) (when (setq ret (album-make-spec-by-height height 480 'VGA)) (setq dest (cons ret dest))) + (when (setq ret (album-make-spec-by-height height 160 'thumbnail)) + (setq dest (cons ret dest))) )) - (setq rest dest) + (unless (file-exists-p + (expand-file-name "thumbnail" image-dest-dir)) + (make-directory + (expand-file-name "thumbnail" image-dest-dir))) + (call-process "convert" nil nil nil + "-resize" (format "%d%%" (aref (car dest) 0)) + file + (expand-file-name + (concat + (file-name-sans-extension + (file-name-nondirectory file)) ".jpg") + (expand-file-name + "thumbnail" + image-dest-dir))) + (setq rest (cdr dest)) (while rest (setq spec (car rest)) - (album-write-html html-dest-dir image-url-prefix + (album-write-html html-dest-dir lang image-url-prefix (if prev-file (file-name-sans-extension (file-name-nondirectory prev-file))) @@ -213,22 +238,74 @@ (expand-file-name "fullsize" image-dest-dir)))) dest)) -(defun album-convert-images (image-dest-dir html-dest-dir +(defun album-convert-images (image-dest-dir html-dest-dir lang image-url-prefix &rest source-images) + (unless html-dest-dir + (setq html-dest-dir image-dest-dir)) (if (and (consp (car source-images)) (null (cdr source-images))) (setq source-images (car source-images))) + (album-make-thumbnails html-dest-dir lang image-url-prefix + source-images) (let (file prev-file) (while source-images (setq file (car source-images)) - (album-convert-image image-dest-dir html-dest-dir + (album-convert-image image-dest-dir html-dest-dir lang image-url-prefix prev-file file (nth 1 source-images)) (setq prev-file file source-images (cdr source-images))))) -(defun album-convert-directory (image-dest-dir html-dest-dir +(defun album-make-thumbnails (html-dest-dir lang image-url-prefix + source-images) + (let ((album + (file-name-nondirectory + (if (eq (aref html-dest-dir (1- (length html-dest-dir))) ?/) + (substring html-dest-dir 0 (1- (length html-dest-dir))) + html-dest-dir))) + file) + (with-temp-buffer + (insert + "\n") + (insert "\n") + (insert "\n") + (insert (format "%s\n" album)) + (insert "\n") + (insert "\n") + (insert (format "

%s

\n" album)) + + (insert " +
+") + (dolist (image-file source-images) + (setq file (file-name-sans-extension + (file-name-nondirectory image-file))) + (insert "") + (insert (format "\"%s\"" + file + (if image-url-prefix + (format "%s/%s/%s" + image-url-prefix grade file) + file))) + (insert "\n")) + (insert " + +
+ + + +") + (write-region (point-min)(point-max) + (expand-file-name "index.html" html-dest-dir))))) + +(defun album-convert-directory (image-dest-dir html-dest-dir lang image-url-prefix source-dir &rest patterns) (let (files) @@ -242,7 +319,7 @@ (directory-files source-dir 'full ".+\\.\\(tiff\\|jpg\\|JPG\\|jpeg\\|gif\\|png\\)$")))) - (album-convert-images image-dest-dir html-dest-dir + (album-convert-images image-dest-dir html-dest-dir lang image-url-prefix files)))