Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 12-02-2005, 08:38 AM   #1
Senior Member
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Command line screenshot of a single window


I'm trying to make a screenshot of a single window from a (bash) script. The "import" utility from ImageMagick has a -window option to specify a window-ID or window-name to grab it non-interactively. But it doesn't seem to work. Google gave me only man-pages with information I already got, and web-pages that only mention "import -window root" to take a shot of the entire screen, which does work, but is not what I'm looking for.

I get the window ID from "xprop", or "xlsclients -l". Example:
bash$ xlsclients -l
Window 0x1a00001:
  Machine:  hko3
  Name:  firefox-bin
  Icon Name:  firefox-bin
  Command:  firefox-bin
  Instance/Class:  firefox-bin/Firefox-bin
So I try:
bash:/tmp$ import -window 0x1a00001 test.jpg
import: UnableToReadXWindowImage (0x1a00001).
import: missing an image filename `test.jpg'.
I also think the second error message is a bit strange: it tells me it's missing a filename, and also mentions the file name?! Am I doing something wrong here?

The window ID seems OK though:
bash$ xprop -id 0x1a00001
WM_CLASS(STRING) = "firefox-bin", "Firefox-bin"
I also tried window-names instead of ID's:
import -window firefox test.jpg
import: NoWindowWithSpecifiedIDExists (firefox). then waits for me to select a window with the mouse, so I suppose the name is incorrect:

import -window firefox-bin test.jpg
import: UnableToReadXWindowImage (firefox-bin).
import: missing an image filename `test.jpg'.
# The name now seem OK, but no screenshot..
A similar problem happens when I try "xwd", the screenshot utility from xfree86 itself:
bash:/tmp$ xwd -id 0x1a00001 -out test.img
X Error of failed request:  BadMatch (invalid parameter attributes)
  Major opcode of failed request:  73 (X_GetImage)
  Serial number of failed request:  434
  Current serial number in output stream:  434
Making screenshots of a single window with The Gimp works perfectly.

Does anybody have an idea what's wrong?
Thanks in advance for any ideas.

PS. I'm running Debian sarge, which has:
ImageMagick version: 6.0.6 05/26/05
Old 12-02-2005, 09:21 AM   #2
Senior Member
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Original Poster
Rep: Reputation: 111Reputation: 111
Update information

I found out that the problem exist only with certain applications like XFCE4-panel and firefox. I can capture xterms, and some other programs witout problems.

Anybody knows how to get a screenshot of firefox non-interactively?


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a single command to list all hardware installed (command line)? davee Linux - Hardware 6 02-28-2009 07:19 PM
Retrieve Window ID in command line.. joely2k Linux - General 3 11-26-2005 11:44 AM
Command line to raise a window? joely2k Linux - General 2 11-25-2005 12:42 PM
How do you start X-window from command line? yekrahs SUSE / openSUSE 2 11-18-2005 09:12 AM
How switch from x-window to the command line backpacker Linux - Newbie 1 06-09-2005 03:56 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:34 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration