How to restrict an image size with phantomjs when capturing screenshots?

1,894 views
Skip to first unread message

Kakembo Muhamed

unread,
Feb 16, 2013, 4:45:04 AM2/16/13
to phan...@googlegroups.com
Hi i am asking if its possible to make a screenshot size restricted to the size i want lets say 960 to 400px somewhere in the code before its captured?

Nicolas Perriault

unread,
Feb 16, 2013, 6:37:00 AM2/16/13
to phan...@googlegroups.com
On Sat, Feb 16, 2013 at 10:45 AM, Kakembo Muhamed <jeff...@gmail.com> wrote:

> Hi i am asking if its possible to make a screenshot size restricted to the
> size i want lets say 960 to 400px somewhere in the code before its captured?

http://casperjs.org/api.html#casper.capture (hint: the clipRect parameter)

Also, you have the viewport method http://casperjs.org/api.html#casper.viewport

++

--
Nicolas Perriault
https://nicolas.perriault.net/
Phone: +33 (0) 660 92 08 67

Kakembo Muhamed

unread,
Feb 17, 2013, 4:00:29 AM2/17/13
to phan...@googlegroups.com, nic...@perriault.net
i failed to instal casperjs on windows there documentation doesnt support beginners.

James Greene

unread,
Feb 17, 2013, 11:00:24 AM2/17/13
to phan...@googlegroups.com

Please suggest what might make it easier for you to understand. Thank you!
~~James

--
You received this message because you are subscribed to the Google Groups "phantomjs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to phantomjs+...@googlegroups.com.
Visit this group at http://groups.google.com/group/phantomjs?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Ariya Hidayat

unread,
Feb 17, 2013, 11:16:27 AM2/17/13
to phan...@googlegroups.com
> Hi i am asking if its possible to make a screenshot size restricted to the
> size i want lets say 960 to 400px somewhere in the code before its captured?

viewportSize is probably what you want:

page.viewportSize = { width: 600, height: 600 };

Note that for "cutting" the screenshot, you can use clipRect:

page.clipRect = { top: 14, left: 3, width: 400, height: 300 };

Please refer to the documentation for details.


Regards,


--
Ariya Hidayat, http://ariya.ofilabs.com
http://twitter.com/ariyahidayat
http://gplus.to/ariyahidayat

Kakembo Muhamed

unread,
Feb 18, 2013, 3:21:00 AM2/18/13
to phan...@googlegroups.com
this is in conjunction with casperjs wright? ok i got this thank you.

Nicolas Perriault

unread,
Feb 18, 2013, 4:06:32 AM2/18/13
to phan...@googlegroups.com
On Mon, Feb 18, 2013 at 9:21 AM, Kakembo Muhamed <jeff...@gmail.com> wrote:

> this is in conjunction with casperjs wright? ok i got this thank you.

Nope, WebPage.viewportSize is builtin PhantomJS.
Reply all
Reply to author
Forward
0 new messages