Friday, October 28, 2011

khtml2png - Take Command Line Web Screenshots on Linux

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!

make install

You can use it to take a screenshot with a command like the following:

/usr/bin/khtml2png2 --display --width 1024 --height 768 /home/you/webshot.png

Be sure to get a free Ubuntu application delivered to you daily by RSS or email by subscribing to The Daily Ubuntu application feed.


  1. is a helping tool for capturing images but I did not get the entire length of the site..

  2. Continue the good work; keep posting more n more n more. what is linux

  3. Trik Jitu Menang Bermain Situs Judi Permainan Sabung Ayam Online Yang Jarang Diketahui Kebanyakan Orang Klik Di Sini

    Agen Sabung Ayam Online Terbaik Dan Juga Terpercaya

    Informasi Terlengkap Mengenai Sabung Ayam