emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Slow image display over network


From: joakim
Subject: Re: Slow image display over network
Date: Fri, 24 Sep 2010 15:41:51 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

Lars Magne Ingebrigtsen <address@hidden> writes:

> address@hidden writes:
>
>> If you look at the imagemagick loader, there is an attempt there at
>> image "pinging", figuring out stuff about images withouth actualy
>> loading them. The pinging there is done to avoid loading an entire image
>> stack when you only want one image index in the stack. Maybe this ping
>> code could be generalized and exposed to lisp. I've noticed the need
>> myself several times.
>
> Yes, that sounds very useful.  If you have the time, could you make this
> info available to the Lisp layer, and I can do some testing?

Meanwhile(I'm out of Emacs hack budget for a while), heres some other
code I had lying around:

(defun emsane-image-size (image-file)
  "Return the size of IMAGE-FILE as a cons."
  ;;TODO I snipped this from "dragbox.el" so it might be reusable
  (with-current-buffer (get-buffer-create "*imagemagic identify*")
    (erase-buffer)
    (call-process "identify" nil "*imagemagic identify*" nil "-verbose" 
image-file) ;; "-ping" sometimes segfaults for me
    (goto-char (point-min))
    (re-search-forward "Geometry: \\([0-9]+\\)x\\([0-9]+\\)")
    (cons (string-to-number (match-string 1))
          (string-to-number (match-string 2)))))


Aparently the "-ping" flag segfaulted for me when I wrote that
snippet(it doesnt seem to do that now). "-verbose" is similar but gives
much more info and is not as efficient as -ping.

The C code would look vaguely similar to this(for the imagemagick loader):

  MagickWand  *ping_wand;
  int siz_x; int siz_y;
  status = MagickPingImage(ping_wand, filename);
  numimages = MagickGetNumberImages(ping_wand);
  MagickGetImageResolution(ping_wand, &siz_x, &siz_y);

To do this properly I would suppose one needs to invent a lisp structure
compatible with the display spec that can hold image meta data, and have
several implementations of the interface, one for imagemagick, one for
when imagemagick isnt available, that could maybe use "file" etc
ad-overengineering-nauseam. (also call the meta function depending on
the image loader)
  
-- 
Joakim Verona



reply via email to

[Prev in Thread] Current Thread [Next in Thread]