Removing overlapping windows in screenshot

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
runningeek11
Posts: 1
Joined: 2011-11-29T08:27:57-07:00
Authentication code: 8675308

Removing overlapping windows in screenshot

Post by runningeek11 »

I am trying to take a screenshot of a specific window by using the following command in Shell on Linux with ImageMagick Version: 6.7.1-0 2011-11-24 Q16

import -descend -window "window name" output.png

The problem I am running into is if the window is behind other windows then I see the overlapping windows. Is there anyway to make it where I do not see the overlapping windows?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Removing overlapping windows in screenshot

Post by magick »

The content of an X11 window that is behind another may not even be defined (for efficiency). Its only after it is brought to the front, does the content get refreshed with exposure events. If you need the entire content of a window, ensure the window is in the front.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Removing overlapping windows in screenshot

Post by anthony »

One way is to use a window manager control tool such as xwit, wmctrl, wmiface, and xdotool, to ensure the desired window is fore-most. The latter is in active development, and can do a lot more than the other older commands.

Basically, you write a script to use one of those tools to select a window (get its window ID) and bring to to the top of the window stack, then give that ID to Imagemagick to grab the window.

Other means of selecting the window is to select the 'active' or current 'focused' window.. For example, this is from my won window capture shell script... It select the 'current' window, raise it, and print its information, from which I get the windows ID.
I then capure it!

Code: Select all

  id=`xwit -current -raise -print | sed 's/:.*//'`
   convert x:"$id" capture-tmp-$$.png
   jiggle_window -t circle -id "$id"
that last command is a separate script that moves the window in a small circle, to indicate the capture is complete.
Get it from http://www.ict.griffith.edu.au/anthony/ ... gle_window

The rest of my "capture_window" script is to rename the captured image to the next available 'sequence number' in my capture directory (gets a listing and works it out). I tie my script to a 'hot key'.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply