<?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; screenshot</title>
	<atom:link href="http://blog.tordeu.com/?feed=rss2&#038;tag=screenshot" 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>Creating Screenshots of Virtual Machines [VirtualBox]</title>
		<link>http://blog.tordeu.com/?p=130</link>
		<comments>http://blog.tordeu.com/?p=130#comments</comments>
		<pubDate>Sun, 27 Nov 2011 23:54:16 +0000</pubDate>
		<dc:creator>tordeu</dc:creator>
				<category><![CDATA[Command Line]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[VirtualBox]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[screenshot]]></category>
		<category><![CDATA[virtual machine]]></category>

		<guid isPermaLink="false">http://blog.tordeu.com/?p=130</guid>
		<description><![CDATA[If you ever wanted to create screenshots of a virtual machine (for a tutorial, a presentation, a forum post or any other reason), you probably already noticed that the VirtualBox GUI does not offer a screenshot function. Although using additional programs (like GIMP, for example) would get the job done, you do not need them, <a href='http://blog.tordeu.com/?p=130'>[...]</a>]]></description>
				<content:encoded><![CDATA[<p>If you ever wanted to create screenshots of a virtual machine (for a tutorial, a presentation, a forum post or any other reason), you probably already noticed that the VirtualBox GUI does not offer a screenshot function.</p>
<p><span id="more-130"></span>Although using additional programs (like GIMP, for example) would get the job done, you do not need them, because VirtualBox does offer screenshot functionality on the command line. And using the built-in function has two advantages:</p>
<ul>
<li>The screenshot will only include what is seen in the virtual machine and won&#8217;t include the VirtualBox window the machine is running in or even the whole Desktop, so there is no need to edit the screenshot.</li>
<li>The screenshots can be made without user-interaction, which is nice if you need to create screenshots automatically with a script or a cron job (e.g. if you want to take a screenshot every 5 minutes &#8211; for whatever reason you might have &#8211; you could completely automate the task).</li>
</ul>
<p>The command to take a screenshot generally looks like this:</p>
<pre>VBoxManage controlvm &lt;uuid&gt; screenshotpng &lt;file&gt;</pre>
<p>or like this</p>
<pre>VBoxManage controlvm &lt;name&gt; screenshotpng &lt;file&gt;</pre>
<p>depending on whether you want to use the UUID or the name of the virtual machine. The name for the virtual machine can be obtained directly from the VirtualBox Manager window or from the window of the running virtual machine:</p>
<div id="attachment_227" class="wp-caption aligncenter" style="width: 703px"><a href="http://blog.tordeu.com/wp-content/uploads/2011/11/VirtualBox-Screenshot3.png"><img class="size-full wp-image-227" title="VirtualBox-Screenshot3" src="http://blog.tordeu.com/wp-content/uploads/2011/11/VirtualBox-Screenshot3.png" alt="Obtaining the name of a virtual machine" width="693" height="379" /></a><p class="wp-caption-text">Obtaining the name of a virtual machine</p></div>
<p>As you can see in the screenshot, the name of the virtual machine is &#8220;Debian Server 1&#8243;.</p>
<p>If we wanted to take a screenshot of the machine and save it as &#8220;server.png&#8221;, we could therefore use the following command:</p>
<pre>VBoxManage controlvm "Debian Server 1" screenshotspng server.png</pre>
<p>And this is what the screenshot would look like:</p>
<div id="attachment_228" class="wp-caption aligncenter" style="width: 730px"><a href="http://blog.tordeu.com/wp-content/uploads/2011/11/snapshot.png"><img class="size-full wp-image-228" title="snapshot" src="http://blog.tordeu.com/wp-content/uploads/2011/11/snapshot.png" alt="Screenshot of a virtual machine" width="720" height="400" /></a><p class="wp-caption-text">Screenshot of the virtual machine</p></div>
<p>&nbsp;</p>
<h2>Appendix: Using UUIDs</h2>
<h3>UUIDs vs Names</h3>
<p>You might also want to think about using the UUID instead of the name of a virtual machine, depending on your situation. Both have their advantages and disadvantages, especially when working with scripts. I am not going to cover this topic in-depth, but let give you something to think about. The advantage of using UUIDs is that you can rename your virtual machines without having to edit the scripts which reference the, directly, because the UUID will stay the same. This is especially useful if you might want to migrate your virtual machine to a different host, because if the new host already has a virtual machine with the same name you have to rename one of them.</p>
<p>But now think of the following situation: You have a virtual machine named &#8220;server&#8221; that you want to migrate to a new host. And you wrote some scripts that somehow work with this VM by using it&#8217;s name. The new host already has a VM named &#8220;server&#8221;, which prevents importing the VM.  So you just rename the VM you want to migreate to &#8220;server2&#8243; and add it, which works great, because there was no VM with the name &#8220;server2&#8243; before.  But now your scripts, which reference a VM called &#8220;server&#8221;, suddenly work on the VM which was already there and not on the VM you migrated (which is now called &#8220;server2&#8243;) and for which the scripts were written. It&#8217;s very easy to forget to alter your scripts to reflect the name change after renaming a virtual machine. But an even bigger problem is: Because there still is a VM called &#8220;server&#8221;, you don&#8217;t even get an error message.</p>
<p>On the other side, two advantages of using the name of the virtual machine that I can think of, are the fact that the name is very easy to see and change in the VirtualBox GUI, so working with VM names in VirtualBox is easier. And if you use the command line,  typing a name is certainly easier and faster (depending on the names you use, of course) than typing the UUID.</p>
<p>Therefore, I personally prefer using the names when using the command line directly and using the UUIDs in scripts.</p>
<h3>Getting the UUID</h3>
<p>In case you want to get the UUID of a virtual machine, you can type the following:</p>
<pre>VBoxManage showvminfo &lt;name&gt;</pre>
<p>This will print a  lot of info, though. To just get the line with the UUID, you can type:</p>
<pre>VBoxManage showvminfo &lt;name&gt; | grep ^UUID</pre>
<p>In this example, you would type:</p>
<pre> VBoxManage showvminfo "Debian Server 1" | grep ^UUID</pre>
<p>which  gives you something like this:</p>
<pre>UUID:        e9e99378-3332-42f4-a6a3-d5490123fe33</pre>
<p>And if you really just want the UUID, you might use the following:</p>
<pre>VBoxManage showvminfo "Debian Server 1" | grep ^UUID | sed 's/UUID: *//'</pre>
<p>to get an output like this:</p>
<p>9e99378-3332-42f4-a6a3-d5490123fe33</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tordeu.com/?feed=rss2&#038;p=130</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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>
