I am having trouble creating images with just data:
(web-http-get
(lambda (con hdr data)
(setq nic-profile-img-data data))
:url "http://pbs.twimg.com/profile_images/494606908385288192/Vq16xxxu_normal.jpeg")
downloads an image from Twitter (yes, I'm writing a Twitter tool).
When I do this:
(insert-image (create-image nic-profile-img-data 'jpeg))
I just get a blank square.
When I do this however:
(insert-image
(progn
(with-temp-file "/tmp/nic.jpg"
(insert nic-profile-img-data))
(create-image "/tmp/nic.jpg" 'jpeg)))
I get a nice picture of a really good looking Englishman.
I don't understand the difference here. I thought it might be encoding of the image data somehow, so I tried all sorts of different decoding and encoding (who understands that stuff in Emacs anyway?), but none of it made any difference.
The create-image with data stuff seems fairly new, and most code I've found uses files. I can use files, but it's an extra layer I didn't want.
How might this work and what, if anything I'm doing wrong?
Platform: Emacs 24-4 on GNU/Linux.
DATA-P
argument tocreate-image
?(buffer-string)
to a variable and use(insert-image (create-image nic-profile-img-data 'jpeg t))
, it works as expected. Maybe try that and then, if successful, try to ascertain the difference between the working and non-working data.