Using IM as a snapshot tool

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
raigal
Posts: 2
Joined: 2011-07-14T11:46:42-07:00
Authentication code: 8675308

Using IM as a snapshot tool

Post 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
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Using IM as a snapshot tool

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
raigal
Posts: 2
Joined: 2011-07-14T11:46:42-07:00
Authentication code: 8675308

Re: Using IM as a snapshot tool

Post 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. :?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Using IM as a snapshot tool

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply