views:

28

answers:

3

Is there an API that can take the content from a div from a webpage and convert it into an image?

A: 

In javascript you could do this with jquery:

$("div").replaceWith('<img />');
DiggyF
Sorry, I didn't really phrase my question well, I've edited it now to be more clear.
ben
+2  A: 

Checkout thumbalizr. It also has an API.

Here's a 1280px screenshot of this page.

To get just the div that you are interested in, find the div's offsets and dimensions, then use any image manipulation library to carve out those coordinates from the entire image starting at (offsetX, offsetY) and having dimensions (width, height).

Anurag
+1  A: 

If the site which includes the div is in your control. Add a border in a unique color to the div. Then use extrenal service like thumbalizr to get the image and clip it in according to the unique color frame.

This setup can run via server side php/gd imagemagick. or similar (javascript/ . Net)

Nir