views:

293

answers:

3

I am receiving a BASE64 encoded string from a WebService. The string represents an HTML page, and I can use built-in ColdFusion functions to convert and display it. However, I need a GIF representation of the HTML page, and I'm wondering if there's any way to do this using ColdFusion.

NOTE: The website I'm working on is ColdFusion 8.

UPDATE: As it turns out, the vendor gave me incorrect instructions (different from their documentation). I don't need to output a GIF of the document they are sending, so this is a non-issue now. However, seeing as the question has received 6 upvotes already, I'm going to leave the it open, as I'm curious if there is - or will be - an answer someday.

A: 

Since CFIMAGE's writeToBrowser doesn't allow you to output a GIF (as you've no doubt found out), you'd have to take the image and save it to the filesystem as a gif, then write an HTML IMG tag pointing to that GIF file.

Edward M Smith
I could be wrong, but my take was their data was plain "html" and wanted to capture some sort of screen shot/image of it.
Leigh
I read it as using a webservice that did the snapshots, and delivered them base-64 encoded response. He then uses CF's built in functions to convert it to a binary image again and display it, via the writeToBrowser action.
Edward M Smith
Well, they did say "The string represents an HTML page". But maybe I am being too literal ;)
Leigh
@Leigh is correct. The vendor is sending me HTML encoded as Base64. I don't believe it can be converted directly to GIF. They are also sending me a GIF encoded as Base64, which works perfect with CFIMAGE.
Eric Belair
@Eric - Right. For HTML you would need the two step process in the link I posted above (URL Thumbnails).
Leigh
+4  A: 

You could save the html to the file system, and use this technique for creating URL Thumbnails

Leigh
Use Virtual File System if you're using CF9: http://www.bennadel.com/blog/1650-Learning-ColdFusion-9-The-Virtual-File-System-RAM-Disk-.htm
Henry
be ware of cfdocument tag, not very reliable rendering CSS.
Henry
Yes, css is problematic with most renderers. Unfortunately, cfdocument is no exception.
Leigh
A: 

You can't write a gif but you can take the base64 and write it to the browser as a png.

Dave Ferguson