Hi - I want to capture different parts of the screen simultaneously and store them to different files. Is there any way of doing this using just one invocation of "import"?
e.g. along the lines of
import -window root -crop 100x100+100+100 a.pnm 300x200+120+30 b.pnm
etc. (although the above doesn't work of course).
The reason I want to do this is because "import" command seems to take several seconds and this being a time critical application I would prefer to call it just once!
Thanks -victor
Capturing multiple images from one "import" invocation
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Capturing multiple images from one "import" invocation
Rather than use import, you can just read the screen using x: from convert
This reads one image from the display, writes it then deletes it from memory, then repeats it with another image from a different area. Of course the final option is an automatic -write, and as the command ends does not need to
be deleted.
But if you want to keep things simple you can still do it the same way just just junk the final write
The [...] is actually a read modifier and is equivelent to a -crop so a single read of the root window may be better.
You can also ask for a specifc window,using the X window ID (which you can get from the "xwininfo" command), or a terminal WINDOWID environment variable, you can use it.
I have updated the special file types for "X" in IM Examples
http://www.imagemagick.org/Usage/files/#x
With the above information (and more).
NOTE that the "display" program can even 'draw' an image into a another applications X window..
From an 'xterm' try this...
The funny bit at the top is because the window to draw into must be the 'child' window of the one given as $WINDOWID. For a Gnome-Terminal, you can just directly assign "window=$WINDOWID".
NOTE the XTERM application does not know of the changes you made to its window. How could it! As such if the window is re-drawn for some reason (remove an obscuring window, change desktop, iconize/de-iconize, scrolls off then on again) then the xterm application will redraw what it things should be present, so destroying the effect.
That is it is temporary!
Now imagine what you can do with this!!!!
Code: Select all
convert x:root'[100x100+50+50]' +repage -write dump1.png +delete \
x:root'[100x100+200+200]' +repage -write dump2.png +delete \
x:root'[100x100+600+50]' +repage dump3.png
be deleted.
But if you want to keep things simple you can still do it the same way just just junk the final write
Code: Select all
convert x:root'[100x100+50+50]' +repage -write dump1.png +delete \
x:root'[100x100+200+200]' +repage -write dump2.png +delete \
x:root'[100x100+600+50]' +repage -write dump3.png +delete \
null:
Code: Select all
convert x:root \
\( +clone -crop 100x100+50+50 +repage -write dump1.png +delete \) \
\( +clone -crop 100x100+200+200 +repage -write dump2.png +delete \) \
\( +clone -crop 100x100+600+50 +repage -write dump3.png +delete \) \
null:
Code: Select all
convert x:$WINDOWID this_terminal.png
http://www.imagemagick.org/Usage/files/#x
With the above information (and more).
NOTE that the "display" program can even 'draw' an image into a another applications X window..
From an 'xterm' try this...
Code: Select all
window=`xwininfo -children -id $WINDOWID |\
sed -n 's/^ *\(0x[^ ]*\).*/\1/p'`; \
convert x:$window -background black \
-draw 'fill black rectangle 40,40 160,160' \
-draw 'stroke red line 50,50 50,150 line 50,150 150,150' \
-draw 'fill lime circle 110,100 80,100' \
-draw 'stroke dodgerblue line 50,150 150,50' \
png:- |\
display -window $window -
NOTE the XTERM application does not know of the changes you made to its window. How could it! As such if the window is re-drawn for some reason (remove an obscuring window, change desktop, iconize/de-iconize, scrolls off then on again) then the xterm application will redraw what it things should be present, so destroying the effect.
That is it is temporary!
Now imagine what you can do with this!!!!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/