* help with image handling
@ 2005-03-24 19:45 Joe Corneli
0 siblings, 0 replies; 2+ messages in thread
From: Joe Corneli @ 2005-03-24 19:45 UTC (permalink / raw)
I want to download images from the web and display them in
an emacs buffer. It seemed to me that the following form
should work, as an example of how to do this:
(let ((content (progn
(set-buffer (get-buffer-create "*scratch*"))
(url-insert-file-contents "http://www.gnu.org/graphics/gnu-head-sm.jpg")
(buffer-string)))
(set-buffer (get-buffer-create "*Nero*"))
(erase-buffer)
(insert-image (create-image content
`,(nero-type-from-extension
extension)
t))))
However, when I switch to the *Nero* buffer, I just see a box,
not the actual image that I thought I was downloading. What
should I be doing differently to actually get the image to display?
Note that this is in
GNU Emacs 22.0.50.4 (powerpc-apple-darwin7.5.0, X toolkit, Xaw3d scroll bars) of 2005-03-24
And the `nero-type-from-extension' function used above is defined here:
(defun nero-type-from-extension (extension)
"Return the image type identifier associated with a file extension."
(cdr (assoc extension '(("jpeg" . jpeg)
("jpg" . jpeg)
("xpm" . xpm)
("xbm" . xbm)
("gif" . gif)
("eps" . postscript)
("pbm" . pbm)
("png" . png)
("tiff" . tiff)))))
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: help with image handling
[not found] <mailman.153.1111695505.28103.help-gnu-emacs@gnu.org>
@ 2005-03-24 20:40 ` Miles Bader
0 siblings, 0 replies; 2+ messages in thread
From: Miles Bader @ 2005-03-24 20:40 UTC (permalink / raw)
Joe Corneli <jcorneli@math.utexas.edu> writes:
> However, when I switch to the *Nero* buffer, I just see a box,
> not the actual image that I thought I was downloading. What
> should I be doing differently to actually get the image to display?
It seems to be some sort of unibyte/multibyte confusion bogosity (not
sure if the code in url-*.el or mm-*.el really does that sort of thing
well or not).
If you do (set-buffer-multibyte nil) in your temp buffer before
downloading the contents, it should work; e.g. the following
successfully inserts a GNU head image for me:
(insert-image
(create-image
(with-temp-buffer
(set-buffer-multibyte nil)
(url-insert-file-contents "http://www.gnu.org/graphics/gnu-head-sm.jpg")
(buffer-string))
nil t))
[Note the third arg to `create-image' tells it to try deducing the image
type from the data in the image.]
-Miles
--
"Unless there are slaves to do the ugly, horrible, uninteresting work, culture
and contemplation become almost impossible. Human slavery is wrong, insecure,
and demoralizing. On mechanical slavery, on the slavery of the machine, the
future of the world depends." -Oscar Wilde, "The Soul of Man Under Socialism"
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-03-24 20:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <mailman.153.1111695505.28103.help-gnu-emacs@gnu.org>
2005-03-24 20:40 ` help with image handling Miles Bader
2005-03-24 19:45 Joe Corneli
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).