brenden / node-webshot

Easy website screenshots in Node.js
2.12k stars 286 forks source link

Options windowSize and captureSelector do not work together #127

Open maksim-zhuk opened 8 years ago

maksim-zhuk commented 8 years ago

When captureSelector option is set, windowSize is being ignored. It would be nice to have an option to specify a block selector and limit an output image with windowSize/shotSize parameters.

nicholasblexrud commented 8 years ago

@maksim-zhuk this might be an issue with phantomjs. Take a look at this issue in phantom js and let me know if it is the same issue as you're describing: Render not honoring viewport size.

maksim-zhuk commented 8 years ago

@nicholasblexrud Don't think these are related. Both captureSelector and windowSize options work perfectly well, my point is that they do not work properly together.

Imagine like when you open any image in a browser, limit the browser's visible area to the half of an image and make a snapshot. The captured result would be only the visible part of an image. Same is here: when range of captureSelector is calculated it should be cropped to windowSize before being passed to renderer.

P.S. I might be conceptually wrong and when captureSelector option is set then no other size-related options (windowSize, shotSize , shotOffset) should take effect, but in this case it might make sense to describe this behavior in docs.