;; (if (re-search-forward "^[ \t]*Timestamp: " nil t)
;; (buffer-substring (match-end 0)(point-at-eol)))))
+;;; for exif 0.6.9
+;; (defun exif-image-file-date-time-original (image-file)
+;; (with-temp-buffer
+;; (call-process "exif" nil t nil
+;; "-t" "DateTimeOriginal"
+;; (expand-file-name image-file))
+;; (goto-char (point-min))
+;; (if (re-search-forward "^[ \t]*Value: " nil t)
+;; (buffer-substring (match-end 0)(point-at-eol)))))
+
+;;; for exif 0.6.15
+;; (defun exif-image-file-date-time-original (image-file)
+;; (with-temp-buffer
+;; (call-process "exif" nil t nil
+;; "-x" (expand-file-name image-file))
+;; (goto-char (point-min))
+;; (if (re-search-forward
+;; "<Date_and_Time__original_>\\([^<>]+\\)</Date_and_Time__original_>"
+;; nil t)
+;; (match-string 1))))
+
+;;; for exiftime Version 1.01
(defun exif-image-file-date-time-original (image-file)
(with-temp-buffer
- (call-process "exif" nil t nil
- "-t" "DateTimeOriginal"
+ (call-process "exiftime" nil t nil
(expand-file-name image-file))
(goto-char (point-min))
- (if (re-search-forward "^[ \t]*Value: " nil t)
+ (if (re-search-forward
+ "^Image Generated: "
+ nil t)
(buffer-substring (match-end 0)(point-at-eol)))))
;; (directory-files
(when (and (not (string-match "^\\.+$" dir))
(setq dir (expand-file-name dir base-dir))
(file-directory-p dir)
- (setq ret (nth 5 (file-attributes dir)))
- (or (> (car ret)(car date-time))
- (and (= (car ret)(car date-time))
- (>= (nth 1 ret)(nth 1 date-time))))
+ ;; (setq ret (nth 5 (file-attributes dir)))
+ ;; (or (> (car ret)(car date-time))
+ ;; (and (= (car ret)(car date-time))
+ ;; (>= (nth 1 ret)(nth 1 date-time))))
(setq ret
(exif-image-file-date-time-original
(car
(defun iphoto-dir-format-time-range-as-album-dir (range year month day)
(let ((time-min (decode-time (car range)))
(time-max (decode-time (cdr range))))
- (format "%s_%s"
+ (format "%s-%s"
(if (and (= (nth 3 time-min) day)
(= (nth 4 time-min) month)
(= (nth 5 time-min) year))
- (format "%02d-%02d-%02d"
+ (format "%02dh%02dm%02ds"
(nth 2 time-min)
(nth 1 time-min)
(nth 0 time-min))
- (format "%d-%02d-%02d-%02d-%02d-%02d"
+ (format "%d-%02d-%02d-%02dh%02dm%02ds"
(nth 5 time-min)
(nth 4 time-min)
(nth 3 time-min)
(if (and (= (nth 3 time-max) day)
(= (nth 4 time-max) month)
(= (nth 5 time-max) year))
- (format "%02d-%02d-%02d"
+ (format "%02dh%02dm%02ds"
(nth 2 time-max)
(nth 1 time-max)
(nth 0 time-max))
- (format "%d-%02d-%02d-%02d-%02d-%02d"
+ (format "%d-%02d-%02d-%02dh%02dm%02ds"
(nth 5 time-max)
(nth 4 time-max)
(nth 3 time-max)
(nth 0 time-max))))))
(defun iphoto-dir-to-album-dir (year month day album-name
- album-dir-root url-root image-url-root)
+ album-dir-root url-root image-url-root
+ album-url-prefix)
(let ((coding-system-for-write 'utf-8-jp-er)
(album-dir-base (expand-file-name album-name album-dir-root))
album-dir album-dir-original ret a-dir-n a-dirs)
(unless (file-exists-p album-dir)
(make-directory album-dir 'parents))
(dolist (file (directory-files dir 'full nil 'no-sort t))
- (call-process "cp" nil nil nil
- "-al"
+ (call-process "ln" nil nil nil
file
- album-dir))
+ album-dir)
+ ;; (call-process "gcp" nil nil nil
+ ;; "-al"
+ ;; file
+ ;; album-dir)
+ )
(with-temp-buffer
(insert ";; -*- mode: emacs-lisp; coding: utf-8-jp-er; -*-\n")
(insert (pp (list
(mapconcat
(lambda (time)
(mapconcat #'identity
- (split-string time "-")
+ (nbutlast
+ (split-string time "[hms]"))
":"))
- (split-string a-dir-n "_")
+ (split-string a-dir-n "-")
"\e$B!A\e(B")))
- (cons 'files
- (directory-files dir nil nil nil t))
- (cons 'exit album-name))))
+ ;; (cons 'files
+ ;; (directory-files dir nil nil nil t))
+ (cons 'exit (concat album-url-prefix album-name)))))
(write-region (point-min)(point-max)
(expand-file-name "dir.desc" album-dir)))
- (unless (file-exists-p album-dir-original)
- (make-directory album-dir-original 'parents))
(dolist (file (directory-files
(expand-file-name
(file-name-nondirectory dir)
(format "~/Pictures/iPhoto Library/Originals/%d/"
year))
'full nil 'no-sort t))
- (call-process "cp" nil nil nil
- "-al"
- file
- album-dir-original))
+ (cond
+ ((string= (downcase (file-name-extension file)) "jpg")
+ (unless (file-exists-p album-dir-original)
+ (make-directory album-dir-original 'parents))
+ (call-process "ln" nil nil nil
+ file
+ album-dir-original)
+ ;; (call-process "gcp" nil nil nil
+ ;; "-al"
+ ;; file
+ ;; album-dir-original)
+ )
+ (t
+ (call-process "ln" nil nil nil
+ file
+ album-dir)
+ ;; (call-process "gcp" nil nil nil
+ ;; "-al"
+ ;; file
+ ;; album-dir)
+ ))
+ )
(call-process "chgrp" nil nil nil
"-R" "www-data"
album-dir)