Hi,
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:
Code:
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:
Code:
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:
Code:
bash$ xprop -id 0x1a00001
WM_CLASS(STRING) = "firefox-bin", "Firefox-bin"
[...]
I also tried window-names instead of ID's:
Code:
import -window firefox test.jpg
import: NoWindowWithSpecifiedIDExists (firefox).
#...it 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:
Code:
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