all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Displaying images does not always work - why not?
@ 2011-06-06 22:53 Nick Dokos
  2011-06-07  2:54 ` Nick Dokos
  2011-06-07  4:39 ` Nick Dokos
  0 siblings, 2 replies; 3+ messages in thread
From: Nick Dokos @ 2011-06-06 22:53 UTC (permalink / raw)
  To: help-gnu-emacs

I had some trouble  with Julien Danjou's nifty google-weather and its corollary
org-google-weather (available from Julien's git repo
git://git.naquadah.org/google-weather-el.git), but most of it turned out to be
some volatility in
what Google provides.

There is a remaining problem however that is driving me up the wall.
Org-google-weather downloads and displays weather information, including GIF
images (partly cloudy etc). It also caches both the information and the images
for 12 hours. When the information is displayed, sometimes the images are fine,
but most of the time they are empty boxes.

Turns out that if I defeat the caching and download the images from Google
they display properly. If I try to display a cached image, I get the
empty box. Here is what I tried:

(setq date '(6 6 2011))
(setq foo (let ((org-google-weather-cache-time 0))
            (org-google-weather)))

(setq bar (org-google-weather))

(equal foo bar) returns t. Evaluating foo and bar in separate windows and
running compare-windows also says they are the same. Doing C-u C-x = and
clicking on the display property of each and comparing them shows no difference.
Nevertheless

(insert foo)

displays the image, whereas

(insert bar)

displays an empty box.

I tried to reduce it to more elemental components, by saving the image part of
the cached file into a different file, called foo.gif. I can display that using
ImageMagick's "display" program (although when I open it in emacs, I get the
binary content). I converted it to a PNG, usinc convert: I can display the PNG
using "display" and I can also open it in emacs: I get the image displayed.

But when I try

(setq i (create-image "foo.png"))
(insert-image i)

I get the dreaded empty box (and the same thing with foo.gif). And btw,
image-type-available-p says t for both gif and png.

What am I missing?

Thanks,
Nick

PS. I tried with both emacs 24.0.50 and emacs 23.1.1 and get the same result in
this last case. If you care to try it out, I've put the foo.png file at

   http://free.linux.hp.com/~nick/foo.png




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Displaying images does not always work - why not?
  2011-06-06 22:53 Displaying images does not always work - why not? Nick Dokos
@ 2011-06-07  2:54 ` Nick Dokos
  2011-06-07  4:39 ` Nick Dokos
  1 sibling, 0 replies; 3+ messages in thread
From: Nick Dokos @ 2011-06-07  2:54 UTC (permalink / raw)
  To: help-gnu-emacs

Nick Dokos <nicholas.dokos <at> hp.com> writes:


> ...
> I tried to reduce it to more elemental components, by saving the image part of
> the cached file into a different file, called foo.gif. ...
> But when I try
> 
> (setq i (create-image "foo.png"))
> (insert-image i)
> 
> I get the dreaded empty box (and the same thing with foo.gif). ...

Well, this last part is a bust: apparently, create-image needs an absolute
pathname - that's why the insert-image doesn't work (and *Messages* makes it
obvious). But that still doesn't explain the original problem:
org-google-weather uses a :data spec for the image, not a :file spec.

Nick








^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Displaying images does not always work - why not?
  2011-06-06 22:53 Displaying images does not always work - why not? Nick Dokos
  2011-06-07  2:54 ` Nick Dokos
@ 2011-06-07  4:39 ` Nick Dokos
  1 sibling, 0 replies; 3+ messages in thread
From: Nick Dokos @ 2011-06-07  4:39 UTC (permalink / raw)
  To: help-gnu-emacs

Nick Dokos <nicholas.dokos <at> hp.com> writes:

> Turns out that if I defeat the caching and download the images from
> Google they display properly. If I try to display a cached image, I
> get the empty box. Here is what I tried:
> 
> (setq date '(6 6 2011))
> (setq foo (let ((org-google-weather-cache-time 0))
>             (org-google-weather)))
> 
> (setq bar (org-google-weather))
> 
> (equal foo bar) returns t. Evaluating foo and bar in separate
> windows and running compare-windows also says they are the
> same. Doing C-u C-x = and clicking on the display property of each
> and comparing them shows no difference.

Despite appearances, they are indeed differeent: I finally did
string-to-list on the image data strings and, comparing them, found
out that the data retrieved from the cache included multibyte
characters whereas the data obtained directly did
not. org-google-weather uses the url package and its caching
mechanism, so there seems to be a bug in url-cache.el. I don't know
what the right solution is, but for now I'm working around the problem
by marking the buffer that url-cache reads into with

 (set-buffer-multibyte nil)

Can somebody please vet this (and fix url-cache if this is correct)?

Thanks,
Nick





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-06-07  4:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-06 22:53 Displaying images does not always work - why not? Nick Dokos
2011-06-07  2:54 ` Nick Dokos
2011-06-07  4:39 ` Nick Dokos

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.