Is there an API that can take a div from a webpage and turn it into an image? [closed]
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this questionIs there an API th开发者_如何学Cat can take the content from a div from a webpage and convert it into an image?
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)
.
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)
In javascript you could do this with jquery:
$("div").replaceWith('<img />');
精彩评论