Page 1 of 1

Using IM as a snapshot tool

Posted: 2011-07-14T11:56:37-07:00
by raigal
Hello everyone,
I am using linux mint 11 and I have been looking for a screenshot application to replace the existing one. In fact there only two things I want from it is saving the image as a .jpeg file and saving to an assigned folder ,like the desktop, with no user interaction besides typing the printscreen button. I have tried many apps like Shutter but unfortunately my computer is old and I can't afford 30-50 mb only for this type of app. I know IM is highly versatile and I was wondering if there was any way I could create a script to do that!

Many thanks guys! :D

Re: Using IM as a snapshot tool

Posted: 2011-07-14T18:49:05-07:00
by anthony
I have this little program attached to a hotkey....

Code: Select all

#!/bin/bash
#
# Get current window focus and capture it as fast as posible.
#
# Then find last number of previous capures (ignore leading zeros),
# and name rename the new capture to the next number (3 digits).
#
cd  # Go Home

# Capture currently active window
id=`xprop -root _NET_ACTIVE_WINDOW | sed 's/.* //'`
#id=`xwit -current -print | sed 's/:.*//'`

convert x:"$id" capture-tmp-$$.png
#jiggle_window -t circle -id "$id"    # notify user by jiggling window

# Find the next number
num=$(ls capture-[0-9]*.png 2>/dev/null | sed -n '$ s/[^0-9]//gp' )
num=$( printf %03d $(expr $num + 1) )

# Rename the captured image
mv capture-tmp-$$.png capture-$num.png
You can adjust the "cd" for your save directory, and the filenames used.
The "xprop" is a standard X windows utility program.

The jiggle_window program (commented out in the above) is another script of mine.
But it is not actually needed. You cane download it from.. though needs the "xwit" executable to use.
http://www.ict.griffith.edu.au/anthony/ ... gle_window
that is used to provide some feedback that the capture is finished. Basically it makes the window in question move in a tight circle a couple of times. Basically just good programming practise.

Re: Using IM as a snapshot tool

Posted: 2011-07-17T12:04:32-07:00
by raigal
Hello anthony,
I run into some trouble.I created an empty file and pasted the script,saved it,renamed it to .sh and allowed it to be run as executable. However,after running it no images pop up in my home folder.My guess is that, I am doing something terribly wrong. :?

Re: Using IM as a snapshot tool

Posted: 2011-07-17T21:00:07-07:00
by anthony
It is typically run from a hot key. and MUST run as a BASH script.

What errors do you get? Did you check your session log?

Note it looks for the currently active X window, (the xprop) to save, and assumes it isn't obsured.

If you just what the whole display you can use x:root instead of the window ID that xprop finds.