From: tomo Date: Fri, 15 Apr 2005 14:09:00 +0000 (+0000) Subject: (www-image-write-html): Add new argument `dest-dir'; change order of X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a5313c4cc45df1efc25a740c61437d1b18b01d1f;p=elisp%2Falbum.git (www-image-write-html): Add new argument `dest-dir'; change order of arguments; expect `prev-file', `file' and `next-file' are relative path; expect `prev-file' and `next-file' are omitted extensions. (www-image-convert-images): Add new argument `dest-dir'; change order of arguments; change `prev-file' and `next-file' to non-optional arguments; modify for `www-image-write-html'. --- diff --git a/www-image.el b/www-image.el index 619b0b4..21b1e26 100644 --- a/www-image.el +++ b/www-image.el @@ -12,34 +12,28 @@ (/ (* width percent) 100.0) (/ (* height percent) 100.0))))) -(defun www-image-write-html (file-base grade - prev-file next-file - prev-grade next-grade) +(defun www-image-write-html (dest-dir + prev-file file next-file + prev-grade grade next-grade) (with-temp-buffer (insert "\n") (insert "\n") - (insert (format "%s\n" - (file-name-nondirectory file-base))) + (insert (format "%s\n" file)) (insert "\n") (insert "\n") - (insert (format "

%s

\n" - (file-name-nondirectory file-base))) + (insert (format "

%s

\n" file)) (if prev-file - (insert (format "" - (file-name-sans-extension - (file-name-nondirectory prev-file))))) + (insert (format "" prev-file))) (insert "[Previous]") (if prev-file (insert "")) (insert "\n") (if next-file - (insert (format "" - (file-name-sans-extension - (file-name-nondirectory next-file))))) + (insert (format "" next-file))) (insert "[Next]") (if next-file (insert "")) @@ -48,7 +42,7 @@ (if prev-grade (insert (format "" prev-grade - (file-name-nondirectory file-base)))) + file))) (insert "[Smaller]") (if prev-grade (insert "")) @@ -57,7 +51,7 @@ (if next-grade (insert (format "" next-grade - (file-name-nondirectory file-base)))) + file))) (insert "[Larger]") (if next-grade (insert "")) @@ -69,15 +63,10 @@ (insert "") - (insert (format "\"%s\"" - (file-name-nondirectory file-base) - (file-name-nondirectory file-base))) + (insert (format "\"%s\"" file file)) (insert "
@@ -86,21 +75,20 @@ ") (unless (file-exists-p - (expand-file-name (symbol-name grade) - (file-name-directory file-base))) + (expand-file-name (symbol-name grade) dest-dir)) (make-directory - (expand-file-name (symbol-name grade) - (file-name-directory file-base)))) + (expand-file-name (symbol-name grade) dest-dir))) (write-region (point-min)(point-max) - (format "%s%s/%s.html" - (file-name-directory file-base) - grade - (file-name-nondirectory file-base))))) + (expand-file-name + (concat file ".html") + (expand-file-name (symbol-name grade) + dest-dir))))) -(defun www-image-convert-images (filename &optional prev-file next-file) +(defun www-image-convert-images (dest-dir + prev-file file next-file) (let* ((ret (with-temp-buffer - (call-process "identify" nil t t filename) + (call-process "identify" nil t t file) (goto-char (point-min)) (and (re-search-forward " \\([0-9]+\\)x\\([0-9]+\\) " nil t) (cons (string-to-number (match-string 1)) @@ -144,48 +132,58 @@ (setq rest dest) (while rest (setq spec (car rest)) - (www-image-write-html (file-name-sans-extension filename) - (aref spec 1) - prev-file next-file + (www-image-write-html dest-dir + (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 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)) - filename - (format "%s/%s/%s.jpg" - (file-name-directory filename) - (aref spec 1) - (file-name-sans-extension - (file-name-nondirectory filename)))) + file + (expand-file-name + (concat + (file-name-sans-extension + (file-name-nondirectory file)) ".jpg") + (expand-file-name + (symbol-name (aref spec 1)) + dest-dir))) (setq prev-grade (aref spec 1)) (setq rest (cdr rest))) (unless (file-exists-p - (expand-file-name "fullsize" - (file-name-directory filename))) + (expand-file-name "fullsize" dest-dir)) (make-directory - (expand-file-name "fullsize" - (file-name-directory filename)))) + (expand-file-name "fullsize" dest-dir))) (call-process "convert" nil nil nil - filename - (format "%s/fullsize/%s.jpg" - (file-name-directory filename) - (file-name-sans-extension - (file-name-nondirectory filename)))) + file + (expand-file-name + (concat + (file-name-sans-extension + (file-name-nondirectory file)) ".jpg") + (expand-file-name "fullsize" dest-dir))) dest)) (let ((rest (append (directory-files - "/archives/RAID2/koukotsu/TAKUHON/" t "^[^0-9].*\\.TIF$") + "/archives/RAID2/koukotsu/TAKUHON/original/" 'full "^[^0-9].*\\.TIF$") (directory-files - "/archives/RAID2/koukotsu/TAKUHON/" t "^[0-9].*\\.TIF$")) + "/archives/RAID2/koukotsu/TAKUHON/original/" 'full "^[0-9].*\\.TIF$")) ;; (directory-files ;; "/archives/RAID2/koukotsu/TAKUHON/" t "\\.TIF$") ) file prev-file) (while rest (setq file (car rest)) - (www-image-convert-images file prev-file (nth 1 rest)) + (www-image-convert-images + "/archives/RAID2/koukotsu/TAKUHON/" + prev-file file (nth 1 rest)) (setq prev-file file rest (cdr rest))))