<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>blog.tordeu.com &#187; xwd</title>
	<atom:link href="http://blog.tordeu.com/?feed=rss2&#038;tag=xwd" rel="self" type="application/rss+xml" />
	<link>http://blog.tordeu.com</link>
	<description>a blog about stuff</description>
	<lastBuildDate>Thu, 25 Apr 2013 07:03:01 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.2</generator>
		<item>
		<title>xwd &#8211; Using xwd To Take Screenshots In Linux</title>
		<link>http://blog.tordeu.com/?p=135</link>
		<comments>http://blog.tordeu.com/?p=135#comments</comments>
		<pubDate>Tue, 22 Nov 2011 00:26:12 +0000</pubDate>
		<dc:creator>tordeu</dc:creator>
				<category><![CDATA[Command Line]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Linux Commands]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[convert]]></category>
		<category><![CDATA[imagemagick]]></category>
		<category><![CDATA[screenshot]]></category>
		<category><![CDATA[x window dump]]></category>
		<category><![CDATA[x window system]]></category>
		<category><![CDATA[xwd]]></category>
		<category><![CDATA[xwinfo]]></category>

		<guid isPermaLink="false">http://blog.tordeu.com/?p=135</guid>
		<description><![CDATA[Introduction One of the possibilities of taking screenshots in Linux is using xwd , a utility of the X Window System. I just want to give a short overview on how to take interactive and non-interactive screenshots, view them and convert them to different formats. Taking Screenshots To take a screenshot you could just open <a href='http://blog.tordeu.com/?p=135'>[...]</a>]]></description>
				<content:encoded><![CDATA[<h2>Introduction</h2>
<p>One of the possibilities of taking screenshots in Linux is using</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">xwd</div></div>
<p>, a utility of the X Window System.</p>
<p>I just want to give a short overview on how to take interactive and non-interactive screenshots, view them and convert them to different formats. <span id="more-135"></span></p>
<h2>Taking Screenshots</h2>
<p>To take a screenshot you could just open a terminal and type &#8221;</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">xwd</div></div>
<p>&#8220;, but by default</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">xwd</div></div>
<p>does not save the screenshot to a file (it outputs the image to stdout). To save the screenshot in a file, you can either use the</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">-out</div></div>
<p>option of</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">xwd</div></div>
<p>:</p>
<pre>xwd -out &lt;filename&gt;</pre>
<p>or redirect the output of</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">xwd</div></div>
<p>to a file using the functionality offered by the shell:</p>
<pre>xwd &gt; &lt;filename&gt;</pre>
<p>Just replace</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&amp;lt;filename&amp;gt;</div></div>
<p>with the name of the file you want to use for your screenshot. Examples:</p>
<pre>xwd -out myshot.xwd</pre>
<p>or</p>
<pre>xwd &gt; myshot.xwd</pre>
<p>Notice the changed mouse pointer after typing one of these commands ? That&#8217;s because you now need to select the window of which you want to take a screenshot. The format</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">xwd</div></div>
<p>uses for the images it is called &#8220;X Window Dump&#8221; and the extension often used is</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">.xwd</div></div>
<p>. I will cover the subject of converting the images to different formats (like JPEG or PNG) later.</p>
<h3></h3>
<h3>Including the Window Frame</h3>
<p>If you want to include the frame of the window in the screenshot, you have to add the</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">-frame</div></div>
<p>option. For example:</p>
<pre>xwd -frame -out myshot.xwd</pre>
<p>or</p>
<pre>xwd -frame &gt; myshot.xwd</pre>
<p>&nbsp;</p>
<h3>Taking Screenshots Of The Whole Desktop</h3>
<p>If you want to create a screenshot of the whole desktop instead of a single window, you can use the</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">-root</div></div>
<p>option for that:</p>
<pre>xwd -root -out myshot.xwd</pre>
<p>or</p>
<pre>xwd -root &gt; myshot.xwd</pre>
<p>&nbsp;</p>
<h3>Automated Screenshots Without Selecting The Window</h3>
<p>It&#8217;s also possible to create screenshots of windows without the need to select them every time. This is especially useful if you want to make numerous screenshots of a single window (e.g. for a tutorial, a presentation, an article etc.).</p>
<p>To do this, you have to tell xwd which window you want to take a screenshot of on the command line, so that it does not have to ask. You can do this either by using the &#8220;resource id&#8221; of the window or the &#8221;</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">WM_NAME</div></div>
<p>property&#8221;. The value of the</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">WM_NAME</div></div>
<p>property basically is the title of your window as it is displayed in the window title bar. Using this to create screenshots can be problematic (With Firefox, for example, this value depends on the title of the active tab, so going to a different tab will change the</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">WM_NAME</div></div>
<p>property of the window).</p>
<p>To determine the resource id or the value of the</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">WM_NAME</div></div>
<p>property, you can use the</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">xwininfo</div></div>
<p>tool. Just type this in the terminal:</p>
<pre>xwininfo</pre>
<p>And then, similar to</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">xwd</div></div>
<p>, click on the window you are interested in. It will then display a bunch of information about the window, which might look like this:</p>
<pre>xwininfo: Window id: <span style="color: #ff0000;">0x40000e7</span> <span style="color: #3366ff;">"Home of the Mozilla Project - Mozilla Firefox"</span>

  Absolute upper-left X:  1287
  Absolute upper-left Y:  70
  Relative upper-left X:  0
  Relative upper-left Y:  0
  Width: 1159
  Height: 1501
  Depth: 24
  Visual: 0x21
  Visual Class: TrueColor
  Border width: 0
  Class: InputOutput
  Colormap: 0x20 (installed)
  Bit Gravity State: NorthWestGravity
  Window Gravity State: NorthWestGravity
  Backing Store State: NotUseful
  Save Under State: no
  Map State: IsViewable
  Override Redirect State: no
  Corners:  +1287+70  -114+70  -114-29  +1287-29
  -geometry 1159x1501+1279-21</pre>
<p>The red and blue color was something I added for clarification. The red thing is the resource ID we are interested in and the blue thing is the</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">WM_NAME</div></div>
<p>property that we also could use.</p>
<p>If we wanted to use the resource ID, we would do it like this</p>
<pre>xwd -id  -out myshot.xwd</pre>
<p>If we want to use the WM_NAME property, we would do this:</p>
<pre>xwd -name  -out myshot.xwd</pre>
<p>&nbsp;</p>
<p>One important thing to note about this approach is that using the -frame option for xwd does not have any effect if you supply the id or name as well. That is, because the resource id for both cases is different. Therefore, if you want to include the window frame, you have to supply the</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">-frame</div></div>
<p>option to</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">xwininfo</div></div>
<p>to retrieve the correct resource id. You would then type:</p>
<pre>xwininfo -frame</pre>
<p>Just to show you that they really differ: In my case, right now, running</p>
<pre>xwininfo</pre>
<p>gives me:</p>
<pre>xwininfo: Window id: 0x40000e7 "Home of the Mozilla Project - Mozilla Firefox"</pre>
<p>while running</p>
<pre>xwininfo -frame</pre>
<p>and clicking on the same, unchanged window, gives me:</p>
<pre>xwininfo: Window id: 0xe002df (has no name).</pre>
<p>&nbsp;</p>
<h2>Viewing Screenshots</h2>
<p>You can view the</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">xwd</div></div>
<p>-screenshots directly with the tool</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">xwud</div></div>
<p>. Just type:</p>
<pre>xwud &lt;filename&gt;</pre>
<p>for example:</p>
<pre>xwud screenshot.xwd</pre>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h2>Converting and Editing Screenshots</h2>
<h3>Converting Screenshots</h3>
<p>You can easily convert the screenshots to &#8220;normal&#8221; image formats like JPEG or PNG with tools like ImageMagick. If you don&#8217;t have ImageMagick installed, it should be available through your repositories. For example, in Ubuntu/Debian you would simply type:</p>
<pre>sudo aptitude install imagemagick</pre>
<p>or</p>
<pre>sudo apt-get install imagemagick</pre>
<p>&nbsp;</p>
<p>Once you have ImageMagick installed, you can convert an</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">xwd</div></div>
<p>image by using</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">convert</div></div>
<p>. For example, to convert an</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">xwd</div></div>
<p>-screenshot named</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">shot.xwd</div></div>
<p>to a JPEG file named</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">shot.jpg</div></div>
<p>, type:</p>
<pre>convert shot.xwd shot.jpg</pre>
<p>You can convert the image to other formats as well, like PNG for example:</p>
<pre>convert sot.xwd shot.png</pre>
<p>&nbsp;</p>
<h3>Editing Screenshots</h3>
<p>I won&#8217;t include a tutorial on editing screenshots here, but I just wanted to mention that you might not have to convert your screenshots to JPG or PNG (or something else) in order to edit them, because your image editor might already be able to load</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">.xwd</div></div>
<p>files. GIMP, for example, can open them directly.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tordeu.com/?feed=rss2&#038;p=135</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
