dalekjs / dalek-browser-chrome

[unmaintained] Chrome Browser bindings for DalekJS
MIT License
15 stars 9 forks source link

Full page screenshots #9

Open ti2m opened 10 years ago

ti2m commented 10 years ago

Is it somehow possible to capture the full page in a screenshot and not just the viewport, like with phantom? I tried setting the viewport, but the hight is always limited by my screen height. I found the related FF issue, so I almost assume same accounts for chrome, just wanted to make sure I'm not missing anything. Thanks!

asciidisco commented 10 years ago

Unfortunately the spec isn't clear about this particular thing & so browser vendors did different implementations. You could execute some JavaScript within the browser, forcing it to scroll down the viewport height, screenshotting, scrolling down ... ... until the end of the page has been reached.

I´ll investigate if we could implement something within Dalek itsels.

ti2m commented 10 years ago

Writing the script to scroll shouldn't be too hard, combining the parts to a complete screenshot might be tricky though. I check, when taking a screenshot with e.g. witdh 1000px, the scrollbar is included within the 1000px. The different parts would need to be cropped, I'll check if you can easily get the scrollbar width, otherwise it will be hard to know where exactly to cut off the image.

Haven't looked at how png's are encoded, but I assume you can't just combine the encoded data into a new file. We would then need to decode all the parts, put them together and encode it again. I have used 'png-js' to decode png's into an linear pixel array of rgba values, but it doesn't support encoding. Wasn't to happy with 'node-pngjs' (don't remember why), but it supports both encoding and decoding. That's the lowest level I see right now that lets you easily combine png's?

jensgro commented 10 years ago

Adding the necessary JS for scrolling down to the dalek-project would be great.