From 722a5b3b3a52342b0d29bab46952b2c0075cb205 Mon Sep 17 00:00:00 2001 From: tomo Date: Mon, 18 Apr 2005 15:15:53 +0000 Subject: [PATCH] (album-write-html): Add new argument `image-url-prefix'. (album-convert-image): Rename argument `dest-dir' to `image-dest-dir'; add new arguments `html-dest-dir' and `image-url-prefix'. (album-convert-images): Likewise. (album-convert-directory): Likewise. --- album.el | 62 ++++++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 38 insertions(+), 24 deletions(-) diff --git a/album.el b/album.el index 3b5bb79..529c188 100644 --- a/album.el +++ b/album.el @@ -41,7 +41,7 @@ (/ (* width percent) 100.0) (/ (* height percent) 100.0))))) -(defun album-write-html (dest-dir +(defun album-write-html (dest-dir image-url-prefix prev-file file next-file prev-grade grade next-grade) (with-temp-buffer @@ -95,7 +95,12 @@ (format "../%s/%s.html" next-grade file) (concat "../fullsize/" file ".jpg"))) (insert "\">") - (insert (format "\"%s\"" file file)) + (insert (format "\"%s\"" + file + (if image-url-prefix + (format "%s/%s/%s" + image-url-prefix grade file) + file))) (insert "
@@ -113,8 +118,11 @@ (expand-file-name (symbol-name grade) dest-dir))))) -(defun album-convert-image (dest-dir prev-file file next-file) +(defun album-convert-image (image-dest-dir html-dest-dir image-url-prefix + prev-file file next-file) (setq file (expand-file-name file)) + (unless html-dest-dir + (setq html-dest-dir image-dest-dir)) (let* ((ret (with-temp-buffer (call-process "identify" nil t t file) @@ -161,19 +169,19 @@ (setq rest dest) (while rest (setq spec (car rest)) - (album-write-html dest-dir - (if prev-file - (file-name-sans-extension - (file-name-nondirectory prev-file))) + (album-write-html html-dest-dir image-url-prefix + (if prev-file + (file-name-sans-extension + (file-name-nondirectory prev-file))) + (file-name-sans-extension + (file-name-nondirectory file)) + (if next-file (file-name-sans-extension - (file-name-nondirectory file)) - (if next-file - (file-name-sans-extension - (file-name-nondirectory next-file))) - prev-grade - (aref spec 1) - (if (nth 1 rest) - (aref (nth 1 rest) 1))) + (file-name-nondirectory next-file))) + prev-grade + (aref spec 1) + (if (nth 1 rest) + (aref (nth 1 rest) 1))) (call-process "convert" nil nil nil "-resize" (format "%d%%" (aref spec 0)) file @@ -183,41 +191,46 @@ (file-name-nondirectory file)) ".jpg") (expand-file-name (symbol-name (aref spec 1)) - dest-dir))) + image-dest-dir))) (setq prev-grade (aref spec 1)) (setq rest (cdr rest))) (unless (file-exists-p - (expand-file-name "fullsize" dest-dir)) + (expand-file-name "fullsize" image-dest-dir)) (make-directory - (expand-file-name "fullsize" dest-dir))) + (expand-file-name "fullsize" image-dest-dir))) (if (string= (downcase (file-name-extension file)) "jpg") (call-process "ln" nil nil nil "-f" file - (expand-file-name "fullsize" dest-dir)) + (expand-file-name "fullsize" image-dest-dir)) (call-process "convert" nil nil nil file (expand-file-name (concat (file-name-sans-extension (file-name-nondirectory file)) ".jpg") - (expand-file-name "fullsize" dest-dir)))) + (expand-file-name "fullsize" image-dest-dir)))) dest)) -(defun album-convert-images (dest-dir &rest source-images) +(defun album-convert-images (image-dest-dir html-dest-dir + image-url-prefix + &rest source-images) (if (and (consp (car source-images)) (null (cdr source-images))) (setq source-images (car source-images))) (let (file prev-file) (while source-images (setq file (car source-images)) - (album-convert-image dest-dir + (album-convert-image image-dest-dir html-dest-dir + image-url-prefix prev-file file (nth 1 source-images)) (setq prev-file file source-images (cdr source-images))))) -(defun album-convert-directory (dest-dir source-dir &rest patterns) +(defun album-convert-directory (image-dest-dir html-dest-dir + image-url-prefix + source-dir &rest patterns) (let (files) (if patterns (dolist (pat patterns) @@ -229,7 +242,8 @@ (directory-files source-dir 'full ".+\\.\\(tiff\\|jpg\\|JPG\\|jpeg\\|gif\\|png\\)$")))) - (album-convert-images dest-dir files))) + (album-convert-images image-dest-dir html-dest-dir + image-url-prefix files))) (provide 'album) -- 1.7.10.4