XWD: how to take SCREENSHOTS in X WINDOW SYSTEM
A screenshot is an image taken from the monitor screen.
It could comprise whole screen or a smaller part of it, usually a window.
XWD TOOL
X Window System provides an utility to dump images from a X Window:
xwd
.xwd stores window images in a special format "xwdump".
This format can be used by other X tools too.
Other tools are also available:
convert from ImageMagick, KSnapshot, gnome-screenshot, ...
We install xwd (in debian, ubuntu):
$ sudo aptitude install x11-apps
CAPTURE WHOLE SCREEN
We could capture entire screen or some window only.
Whole screen in X Window System is associated also to a window: the root window.
Getting root window screenshots:
$ xwd -root -out test_image
A file named test_image appears:
$ file test_image
test_image: XWD X Window Dump image data, "xwdump", 1280x1024x24
$ ls -l test_image
5246059 May 1 19:22 test_image
We observe xwdump format does not compress the image.
COMPRESS THE IMAGE IN A SMALLER SIZE FORMAT
Imagemagick tool suite provides convert utility:
$ aptitude install imagemagick
We try to convert into JPG format. convert tool detects output file format automatically based on its extension.
$ convert -verbose test_image test_image.jpg
$ ls -l test_image*
5246059 May 1 19:22 test_image 95069 May 1 19:27 test_image.jpg
Fifty times smaller, it looks good.
Lets try PNG format:
$ convert -verbose test_image test_image.png
test_image XWD 1280x1024 1280x1024+0+0 8-bit DirectClass 5.246MB 0.080u 0:00.100 test_image=>test_image.png XWD 1280x1024 1280x1024+0+0 8-bit PseudoClass 4c 4.1KB 0.160u 0:00.190
$ ls -l test_image*
5246059 May 1 19:22 test_image 95069 May 1 19:27 test_image.jpg 5147 May 1 19:30 test_image.png
PNG format is usually more suitable for text, diagrams, drawn images, etc.
JPEG one is more suitable for pictures.
WATCH THE SCREENSHOT
We will use xloadimage tool. It reproduces JPG and PNG image formats but not xwdump one.
$ aptitude install xloadimage
$ xloadimage test_image.jpg
$ xloadimage test_image.png
CAPTURE A WINDOW SNAPSHOT (not the whole screen)
xwd by default waits until you select a window by clicking with the mouse on it.
$ xwd -o test_image
After clicking in the window you want to capture, test_image file will appear.
If you know the window property name, you can select that window without clicking with the mouse on it:
$ xprop WM_NAME
# to query the window name first time you also need to select the window using the mouse.E.g:
$ xwd -out emacs_image -name "emacs@myPC.myDomain"
NOTE: Window has to be visible in the window manager or result will be a black image.
RESIZE AN IMAGE
Convert tool provides resize option:
$ convert -verbose test_image -resize 800x600 test_image02.png
SHOW AN IMAGE IN A WEB PAGE
Once we have created a small image, we could show it in a HTML web page.
<img> tag is needed:
E.g:
<img border="0" height="190" width="200" src="http://4.bp.blogspot.com/../vp60_dialog.png" />
src atribute shows image source URL.
height="190" scales image height to 190 pixels.
width="200" scales image width to 200 pixels.
We could also use an image to create a HTML link: (<a> tag)
<a href="http://linuxclues.blogspot.com" alt="VP6 settings dialog">
<img border="0" height="190" width="200" src="http://4.bp.blogspot.com/../vp60_dialog.png" />
</a>
Now, when you click in the image you will jump to this blog.
alt atribute shows a text for browsers which do not display images.
REFERENCE
$ man xwd
http://www.w3schools.com/html/html_images.asp
0 comentarios:
Post a Comment