[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
16 Apr 2005 16:49:48 +0200
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3
For those who may find this useful:
;;; tumme.el --- use dired to browse your images as thumbnails
;; Copyright (C) 2005 Mathias Dahl
;; Version: 0.1
;; Keywords: images, thumbnails, dired
;; Author: Mathias Dahl <address@hidden>
;; Maintainer: Mathias Dahl
;; URL: http://www.emacswiki.org/cgi-bin/wiki/Tumme
;; This file is not part of GNU Emacs.
;; This is free software; you can redistribute it and/or modify it
;; under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; This is distributed in the hope that it will be useful, but WITHOUT
;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
;; License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;; About the name: tumme means thumb in Swedish. Google did not give
;; me any hits for "tumme.el" so I thought it would be safe to use.
;; I needed a program to browse, organize and tag my pictures. I
;; got tired of the old gallery program I used as it did not allow
;; multi-file operations easily. Also, it put things out of my
;; control. Programs that did allow multi-file operations did not do
;; what I wanted it to.
;; So, I got the idea to use the wonderful functionality of emacs and
;; `dired' to do it. It would allow me to do almost anything I wanted,
;; which is basically just to browse all my pictures in an easy way,
;; letting me manipulate and tag them. `dired' already provide all the
;; file handling and navigation facilities; I only needed to add some
;; functions to display the images.
;; I briefly tried out thumbs.el, and although it seemed more
;; powerful than this package, it did not work the way I wanted to. It
;; was too slow to created thumbnails of all files in a directory (I
;; currently keep all my 2000+ images in the same directory) and
;; browsing the thumbnail buffer was slow too. tumme.el will not
;; create thumbnails until they are needed and the browsing is done
;; quickly and easily in dired.
;; `tumme' stores the thumbnail files in `tumme-dir' using the file
;; name format ORIGNAME.thumb.ORIGEXT. For example
;; Feedback is welcome, especially now when this is so fresh.
;; * The convert program from the ImageMagick package
;; First, do M-x tumme-dired-folder RET. This will setup a useful
;; window- and buffer-configuration for you.
;; The following keybindings works quite well, try them out and you
;; will get a feel for how the package works:
;; (define-key dired-mode-map (kbd "C-S-n") 'tumme-next-line-and-display)
;; (define-key dired-mode-map (kbd "C-S-p") 'tumme-previous-line-and-display)
;; (define-key dired-mode-map (kbd "C-S-<return>") 'tumme-display-thumbs)
;; Version 0.1, 2005-04-16
;; * First release, only browsing support for now.
;; I'm not sure if I really consider this a bug, but in order to work
;; well, `tumme' require that all your images have unique names. The
;; reason is the way the thumbnail file name is generated. I will
;; probably not fix this problem as my images all have unique names.
;; - Add tagging capabilities. My plan is to use a simple text file as
;; a database and just add the tag information semi-colon separated
;; and appended to the file name. That would allow using things like
;; `occur', `flush-lines' and `keep-lines'.
;; - Commands to open the images in full size, either in an emacs
;; buffer or external program, or both.
;; - Find some way of toggling on and off really nice keybindings (for
;; example, using C-n or <down> instead of C-S-n) to the interactive
;; - Functionality to display the varius tags next to the picture.
;; - Command to refresh thumbnail images. For now, you have to delete
;; the old files manually.
;; - Commands to create simple HTML-albums, where the images will be
;; browsable per tag, date file name etc.
(defgroup tumme nil
"Use dired to browse your images as thumbnails"
(defcustom tumme-dir "~/.tumme/"
"*Directory where thumbnail images for are stored."
(defcustom tumme-file-name-display-format "\n%s"
"*Format used to display the file name to the right of the
picture. `%s' is the file name. If you want extra space between each
thumbnail, add extra newlines at the end of the format. If you want to
have the file name next to the thumbnail, use no newline at all."
(defcustom tumme-thumb-size 100
"Size of thumbnails, in pixels"
(defun tumme-ins-img (file)
"For now, just a wrapper for insert image file."
(defun tumme-thumb-name (file)
"Return thumbnail file name for FILE"
(file-name-sans-extension (file-name-nondirectory file))
(defun tumme-create-thumb (file)
"Using the convert program, create thumbnail image for FILE and
place it in `tumme-dir'"
(let* ((size (int-to-string tumme-thumb-size))
"convert -size %sx%s %s -resize %sx%s +profile \"*\" %s"
(if (file-exists-p tumme-dir)
(if (not (file-directory-p tumme-dir))
(error "%s exists but is not a directory!" tumme-dir))
(shell-command command nil)))
(defun tumme-next-line-and-display ()
"Move to next dired line and display thumbnail image"
(defun tumme-previous-line-and-display ()
"Move to previous dired line and display thumbnail image"
(defun tumme-dired-folder ()
"Convenience command that:
- Opens dired in folder specified by the user
- Splits the window horizontally
- Set truncate-lines to t
(let ((buf (get-buffer-create "*tumme*")))
(setq truncate-lines t)
(defun tumme-display-thumbs (arg)
"Display thumbnail images of all marked files in buffer *tumme*. If
a thumbnail image does not exist for a file, it is created on the
fly. With prefix arg, display only thumbnail for file at point (this
is useful if you have marked some files but want to show another
Recommended usage is to split the current frame horizontally so that
you have the dired buffer in the left window and the *tumme* buffer in
the right window.
(let ((buf (get-buffer-create "*tumme*"))
curr-file thumb-name files)
(setq files (list (dired-filename-at-point)))
(setq files (dired-get-marked-files)))
(setq curr-file x)
(setq thumb-name (tumme-thumb-name curr-file))
(if (not (file-exists-p thumb-name))
(if (not (= 0 (tumme-create-thumb curr-file)))
(error "Thumb could not be created")))
(insert (format tumme-file-name-display-format
;;; tumme.el ends here
|[Prev in Thread]
||[Next in Thread]|
- tumme.el 0.1,
Mathias Dahl <=