viewportSize seems not to work with PhantomJS
phantomjs, viewport
Solution
This is a known issue but I found a workaround:
- Load the page into an iframe of whatever size you like.
- Render a screenshot clipped to the rectangle of the iframe.
There is code to do it in this repository: https://github.com/jbeuckm/Splasher
Problem
Shouldn't the output from this PhantomJS script be 240x320 pixels? I'm getting a large, default-sized image. clipRect() would seem to render the correct size image, but I need the responsive content of the page to reflect the actual browser window size. ``` var page = require('webpage').create(); page.viewportSize = { width: 240, height: 320 }; page.open('http://cnn.com', function (status) { if (status !== 'success') { console.log('Unable to load the address!'); } else { window.setTimeout(function () { page.render('default.png'); phantom.exit(); }, 200); } }); ```