Linux Box Admin
Trusted Remote Administration
logo

Tilde
What's new
Articles
Micro HowTos
About
Contact







Index arrow Micro HowTos

index of all micro how-tos
arrow Userland

Screenshots through Xvfb
(1 vote)
Sunday, 28 October 2007
   
    Screenshots through Xvfb    
     
       
 
Xvfb acts like a normal X server, but insted of writing the output to the graphics adapter, it writes the graphical output in a binary format into memory. This gives us the opportunity to capture any window running at the Xvfb DISPLAY.
 
Xvfb is included in standard Xorg installations and can be run with a couple of basic parameters.
 
Xvfb :1 -screen 0 1400x2000x24
 
This tells the Xvfb to run on DISPLAY number 1 and screen number 0 with resolution width of 1400 and height 2000 in 24 bit color depth. 
 
 Now we can capture the screen of any window running in the Xvfb DISPLAY/screen with xwd utility.
We have to tell the xwd which screen to capture by either setting the DISPLAY environment variable:
export DISPLAY=:1.0 
 
or by adding a -display and -screen parameters to the xwd tool. Taking the first approach we issue:
 
 xwd -root -silent > screen.xwd
 
 Now we have a binary file screen.xwd. In order to convert the xwd file to more convenient format we have 2 utilities - xwdtopnm and pnmtojpeg. The first converts the xwd to pnm and the second from pnm to jpeg image format. 
 
Now to put it all together: 
 
xwd -root -silent | xwdtopnm |pnmtojpeg > screen.jpg
   
       
         
 



Copyright © 2006,2007 Linux Box Admin.

 
My NHL fan blog