khtml2png is a helpful tool for capturing an image of a webpage with ease. It's nice to use because it will get the entire length of the site, no matter whether it is fully visible in the browser. And, it sure beats shell scripting Firefox to open on a different display and capturing an image with Imagemagick, which is a royal pain in the butt. I embed this application in PHP scripts to create web design roundups over at my other blog. I was able to capture 75 minimal web designs without much hassle.
Example of a khtml2png webshot
This application is a little harder to install because it's not in the Ubuntu repositories. I couldn't find a Deb file, so you'll have to compile it from scratch. Scratch that! I found one at Sourgeforge. Install that, or compile with the directions below. That being said, if someone wants to post a link to a Deb file or a repository, I would love you forever. You need to have a few packages compiled to use khtml2png, including g++, KDE 3.x, kdelibs for KDE 3.x (kdelibs4-dev), zlib (zlib1g-dev), and cmake. This command should work:sudo apt-get install g++ kdelibs zlib1g-dev cmake
You may need more packages than that. It's hard for me to tell because I have so many already installed ;-) Post in the comments if you need help. After that, compile it!./configure
make
make install
You can use it to take a screenshot with a command like the following:
/usr/bin/khtml2png2 --display
Be sure to get a free Ubuntu application delivered to you daily by RSS or email by subscribing to The Daily Ubuntu application feed.
Friday, July 24, 2009
khtml2png - Take Command Line Web Screenshots on Linux
Posted by
Mary
at
1:23 PM
Subscribe to:
Post Comments (Atom)

11 comments:
If you want an image of a web page, and you're using Firefox, ScrenGrab might be even easier:
https://addons.mozilla.org/en-US/firefox/addon/1146
Easy to install (just like any other FF add-on) and fairly flexible to boot.
@Greg:
I haven't heard of that one yet. Is there any way to script it, or is it purely a graphical tool?
That is very awesome!
That way i could (for example) make a cron entry so it grabs a screen of my favorite blog every day. For offline use.
You could make a deb for the rest of us by using checkinstall ;-)
guest blogger invitation
Hello,
This is Rose writing from www.huliq.com. I visited your blog and liked your content.
Would you be interested to send us a guest post on any of the issues related to the topics that you cover in your blog. We will publish it in our site www.huliq.com
In return with each guest blog we will give one link in the author's byline back to your blog. We only ask that the guest post ( we prefer it be a news coverage, sources can be Google News, CNN, MSNBC, Yahoo News, BBC and others) be a unique story and not be published in your blog.
HULIQ is indexed by Google News and Google requires that the length of the unique news is at least 5 paragraphs. We desire it to be at least 6 paragraphs if possible. And that all need to be a unique content. Once you send us a new story totally unique we will immediately publish it with you link in it, and within 15 minutes it should be indexed by Google News.
Also, please structure author byline as follows:
author's name:
author's e-mail:
author's blog url:
Please let me know if you may have any questions about www.huliq.com.
If you want to consult the topic with me first that's perfectly fine as well.
Many thanks
ruzik.mail@gmail.com
I actually like using Perl w/ Selenium's capture_entire_page_screenshot_ok function.
Hi
Installed in Jaunty on EeePC 901 as per yr guide without errors.
When I try to run it from CLI (used yr command) I get this
khtml2png2: cannot connect to X server --width
Any idea what this is about?
Thanks
Paul
See, this is why Linux will never catch on. Too much command line stuff that you can expect the average user t...ahhhhh, just kidding!!!
But you know some dipstick will come in a say that.
Sure there are probably nicer UI using ways to do this but Im gonna have to try this... just because.
@Mary,
Sorry - didn't check back 'til now. No - to the best of my knowledge, ScreenGrab is just a GUI add-on for interactive use w/Firefox. If there's a way to script it's use, I'm unaware of it.
Hi Mary. I just discovered your Blog today. There was a link to this on http://ubuntuguide.org/wiki/Ubuntu:Jaunty
You have things very well presented.
apt-get install kdelibs4-dev
Don't forget that.
Post a Comment