Archived from the Transloadit support forum. Originally posted on March 13, 2014; details may be outdated, see our docs for current behavior. Original thread
Hey,
Currently I use screenshot robot for generating some type of page facebook share preview.
This preview should contain only part of the page.
I tried to use phantomjs app for that and it actually works fine, doing screenshot by css selector.
In phantomjs it is done like this:
var getBoundingRect = function() {
return page.evaluate(function(selector) { return document.querySelector(selector).getBoundingClientRect(); }, SELECTOR); }; page.clipRect = getBoundingRect();
var b64 = page.renderBase64(‘PNG’);
I don’t like phantomjs solution because there is issues with bunch of simultaneous requests; just phantomjs built-in server isn’t enough and requests should be queued somewhere (and queue should be accessible through phantomjs that could be a problem too because there’s possible incompatible nodejs queue-cli libraries). Moreover, screenshot requests have certain performance requirements that may result in incresing number of servers to handle it.
I don’t really want to mess with that all, and, since I’m already using transloadit media handling, I decided to try transloadit screenshot robot.
There’s no option to set selectors to screenshot only part of page. Currently I’m rendering different static page for that.
So proposal is to add css selector to screenshot robot. I know that I could pass screenshot to cropping robots but it isn’t looks good. Actually, it isn’t very important for me, I could live with static rendering or different page.
More important if how robust screenshot robot? Would it work with something like 5 requests per second? (it’s unprobable but possible scenario)
Thanks,
Igor