:group 'image-dired)
(defcustom image-dired-cmd-create-thumbnail-program
- "convert"
+ (executable-find "convert")
"Executable used to create thumbnail.
Used together with `image-dired-cmd-create-thumbnail-options'."
:type 'string
:group 'image-dired)
(defcustom image-dired-cmd-create-temp-image-program
- "convert"
+ (executable-find "convert")
"Executable used to create temporary image.
Used together with `image-dired-cmd-create-temp-image-options'."
:type 'string
:group 'image-dired)
(defcustom image-dired-cmd-rotate-thumbnail-program
- "mogrify"
+ (executable-find "mogrify")
"Executable used to rotate thumbnail.
Used together with `image-dired-cmd-rotate-thumbnail-options'."
:type 'string
:group 'image-dired)
(defcustom image-dired-cmd-rotate-original-program
- "jpegtran"
+ (cond ((executable-find "jpegtran"))
+ ((executable-find "convert")))
"Executable used to rotate original image.
Used together with `image-dired-cmd-rotate-original-options'."
:type 'string
:group 'image-dired)
(defcustom image-dired-cmd-rotate-original-options
- "%p -rotate %d -copy all -outfile %t \"%o\""
+ (when image-dired-cmd-rotate-original-program
+ (pcase image-dired-cmd-rotate-original-program
+ ((pred (lambda (x) (string-match-p "jpegtran" x)))
+ "%p -rotate %d -copy all -outfile %t \"%o\"")
+ ((pred (lambda (x) (string-match-p "convert" x)))
+ "%p -rotate %d \"%o\" %t")))
"Format of command used to rotate original image.
Available options are %p which is replaced by
`image-dired-cmd-rotate-original-program', %d which is replaced by the
:group 'image-dired)
(defcustom image-dired-cmd-write-exif-data-program
- "exiftool"
+ (executable-find "exiftool")
"Program used to write EXIF data to image.
Used together with `image-dired-cmd-write-exif-data-options'."
:type 'string
:group 'image-dired)
(defcustom image-dired-cmd-read-exif-data-program
- "exiftool"
+ (executable-find "exiftool")
"Program used to read EXIF data to image.
Used together with `image-dired-cmd-read-exif-data-program-options'."
:type 'string
(defun image-dired-create-thumb (original-file thumbnail-file)
"For ORIGINAL-FILE, create thumbnail image named THUMBNAIL-FILE."
+ (unless image-dired-cmd-create-thumbnail-program
+ (error "image-dired-cmd-create-thumbnail-program is nil"))
(let* ((width (int-to-string image-dired-thumb-width))
(height (int-to-string image-dired-thumb-height))
(modif-time (format "%.0f" (float-time (nth 5 (file-attributes
"Move to next line and display properties."
(interactive)
(let ((goal-column (current-column)))
- (next-line))
+ (forward-line 1)
+ (move-to-column goal-column))
;; If we end up in an empty spot, back up to the next thumbnail.
(if (not (image-dired-image-at-point-p))
(image-dired-backward-image))
"Move to previous line and display properties."
(interactive)
(let ((goal-column (current-column)))
- (previous-line))
+ (forward-line -1)
+ (move-to-column goal-column))
;; If we end up in an empty spot, back up to the next
;; thumbnail. This should only happen if the user deleted a
;; thumbnail and did not refresh, so it is not very common. But we
(progn
(setq width (image-dired-display-window-width))
(setq height (image-dired-display-window-height))
+ (unless image-dired-cmd-create-temp-image-program
+ (error "image-dired-cmd-create-temp-image-program is nil"))
(setq command
(format-spec
image-dired-cmd-create-temp-image-options
(defun image-dired-rotate-thumbnail (degrees)
"Rotate thumbnail DEGREES degrees."
+ (unless image-dired-cmd-rotate-thumbnail-program
+ (error "image-dired-cmd-rotate-thumbnail-program is nil"))
(if (not (image-dired-image-at-point-p))
(message "No thumbnail at point")
(let ((file (image-dired-thumb-name (image-dired-original-file-name)))
(defun image-dired-rotate-original (degrees)
"Rotate original image DEGREES degrees."
- (if (not (image-dired-image-at-point-p))
- (message "No image at point")
- (let ((file (image-dired-original-file-name))
- command)
- (unless (eq 'jpeg (image-type file))
- (error "Only JPEG images can be rotated!"))
- (setq command (format-spec
- image-dired-cmd-rotate-original-options
- (list
- (cons ?p image-dired-cmd-rotate-original-program)
- (cons ?d degrees)
- (cons ?o (expand-file-name file))
- (cons ?t image-dired-temp-rotate-image-file))))
- (if (not (= 0 (call-process shell-file-name nil nil nil
- shell-command-switch command)))
- (error "Could not rotate image")
- (image-dired-display-image image-dired-temp-rotate-image-file)
- (if (or (and image-dired-rotate-original-ask-before-overwrite
- (y-or-n-p
- "Rotate to temp file OK. Overwrite original image? "))
- (not image-dired-rotate-original-ask-before-overwrite))
- (progn
- (copy-file image-dired-temp-rotate-image-file file t)
- (image-dired-refresh-thumb))
- (image-dired-display-image file))))))
+ (unless (image-dired-image-at-point-p)
+ (message "No image at point"))
+ (unless image-dired-cmd-rotate-original-program
+ (error "image-dired-cmd-rotate-original-program is nil"))
+ (let ((file (image-dired-original-file-name))
+ command)
+ (unless (eq 'jpeg (image-type file))
+ (error "Only JPEG images can be rotated!"))
+ (setq command (format-spec
+ image-dired-cmd-rotate-original-options
+ (list
+ (cons ?p image-dired-cmd-rotate-original-program)
+ (cons ?d degrees)
+ (cons ?o (expand-file-name file))
+ (cons ?t image-dired-temp-rotate-image-file))))
+ (if (not (= 0 (call-process shell-file-name nil nil nil
+ shell-command-switch command)))
+ (error "Could not rotate image")
+ (image-dired-display-image image-dired-temp-rotate-image-file)
+ (if (or (and image-dired-rotate-original-ask-before-overwrite
+ (y-or-n-p
+ "Rotate to temp file OK. Overwrite original image? "))
+ (not image-dired-rotate-original-ask-before-overwrite))
+ (progn
+ (copy-file image-dired-temp-rotate-image-file file t)
+ (image-dired-refresh-thumb))
+ (image-dired-display-image file)))))
(defun image-dired-rotate-original-left ()
"Rotate original image left (counter clockwise) 90 degrees."
(old-value (image-dired-get-exif-data file "ImageDescription")))
(if (eq 0
(image-dired-set-exif-data file "ImageDescription"
- (read-string "Value of ImageDescription: "
- old-value)))
+ (read-string "Value of ImageDescription: "
+ old-value)))
(message "Successfully wrote ImageDescription tag.")
(error "Could not write ImageDescription tag")))))
(defun image-dired-set-exif-data (file tag-name tag-value)
"In FILE, set EXIF tag TAG-NAME to value TAG-VALUE."
+ (unless image-dired-cmd-write-exif-data-program
+ (error "image-dired-cmd-write-exif-data-program is nil"))
(let (command)
(setq command (format-spec
image-dired-cmd-write-exif-data-options
(defun image-dired-get-exif-data (file tag-name)
"From FILE, return EXIF tag TAG-NAME."
+ (unless image-dired-cmd-read-exif-data-program
+ (error "image-dired-cmd-read-exif-data-program is nil"))
(let ((buf (get-buffer-create "*image-dired-get-exif-data*"))
command tag-value)
(setq command (format-spec