Skip to main content
Inspiring
April 24, 2008
Question

taking screengrabs of sites in CF

  • April 24, 2008
  • 5 replies
  • 666 views
hi - here's a good one for you..

we want to be able to take a screengrab of a site's index page and save it as jpg (we have a list of 1000 sites we want to do this for)

i'm thinking that it can probably be done using cfhttp and then outputting the obtainted html within cfdocument tags to create a jpg of the page

then we could use cfimage to reduce the size of that resulting image to 400px wide

before i spend the next 10-20 hours barking up the wrong tree with this; does anyone have any comments / suggestions / heads up's to make?

anyone done this before, ran into any problems? got an easier route to suggest?

thanks very much indeed.
This topic has been closed for replies.

5 replies

BKBK
Community Expert
Community Expert
May 1, 2008
Good find, Azadi.

Inspiring
May 1, 2008
just stumbled upon this:
http://stylizedweb.com/2008/04/26/website-screenshots-services/

the last entry, a web service, looks interesting....
haven't tried it yet, though...

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
BKBK
Community Expert
Community Expert
April 28, 2008
I agree with Mr Black. The weak link in the chain is cfdocument. It is not yet capable of reproducing an arbitrary website display as we see it in the browser.
Inspiring
April 24, 2008
it is in fact extremely easy to do in CF8. here's a working proof:
[warning: a dir "thumbnails" will be created if it does not exist OR
DELETED AND RE-CREATED IF IT DOES in the executed template's folder. the
it is the cfpdf's doings, not mine...]

<!--- --->
getting url... <cfflush>
<cfhttp url=" http://www.sabai-dee.com" resolveurl="yes" result="myres">
... got it!<br>
creating in-memory pdf... <cfflush>
<cfdocument format="pdf" name="mypdf">
<cfoutput>#myres.filecontent#</cfoutput>
</cfdocument>
...pdf created!<br>
generating thumbnail... <cfflush>
<cfpdf action="thumbnail" source="mypdf" overwrite="yes">
...done!<br><br>
here it is:<br><br>
<img src="thumbnails/thumbnail_page_1.jpg"><br><br>
<a href=" http://www.sabai-dee.com" target="sdc">compare to original</a>
<!--- --->

there are numerous other settings one can employ in all the above-used
cf tags to control size, quality and other aspects of the generated
jpeg. and if you throw <cfimage> into the mix, the capabilities are
pretty much limitless...

hth


Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Participating Frequently
April 24, 2008
Cool. Works OK for basic and simple HTMLs. However, when I try "www.yahoo.com", I get garbage. Flash, complex page structure, etc. Dont' forget to use useragent for IE or some other advanced browser, otherwise you will get plain HTML. I used:
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; InfoPath.1)"

There is a real solution: http://www.cftagstore.com/tags/cfxwebthumb.cfm.
Inspiring
April 24, 2008
happysailingdude wrote:
> outputting the
> obtainted html within cfdocument tags to create a jpg of the page

This section is outside of CF abilities. Where are you outputting the
HTML? ColdFusion is not a browser, it won't render the HTML.

You would need some tool that renders the HTML and creates the JPG for
you. I do not know what this might be, but I am sure it is out there
somewhere.