image-magick screenshot


Forum: Other Help Topics
Topic: image-magick screenshot
started by: henk1955

Posted by henk1955 on Nov. 22 2004,11:33
Code Sample
#!/bin/bash

((cnt = 0))

#find a filename#
while [ -e $HOME/screenshot-$cnt.jpg ]; do
 # Increment cnt
 ((cnt++))
done

#give some time to take a pose
sleep 3

#shoot
/opt/imagemagick/bin/import -window root $HOME/screenshot-$cnt.jpg

i use this little script to take screenshot of my desktop
it needs the imagemagick.dsl
it will take a screenshot of the desktop and place a file screenshot#.jpg in the /home/dsl directory. everey time you take a new shot the filename is numbered up
you can create a menu item or desktop icon to "push the camera button"

Posted by mikshaw on Nov. 22 2004,13:29
I have a similar script, but mine uses the current date as the filename.  I'll have to include $cnt so it no longer overwrites multiple same-day screenshots.  Thanks.

Also, ImageMagick has it's own pause option "-pause [# of seconds]"...no better than using sleep, but just thought I'd mention.

Posted by AwPhuch on Nov. 23 2004,14:52
Outstanding...excellent

Great job guys!

Brian
AwPhuch

Posted by mikshaw on Nov. 23 2004,16:29
Another addition is specifying compression as an argument:

if [ ! $1 ]; then
      echo "no compression specified (1-100)"
else    
import -pause 5 -window root -quality $1 ${FILENAME}
       if [ -r ${FILENAME} ]; then
       echo "image saved to ${FILENAME}"
       else
       echo "could not save ${FILENAME}"
       fi
fi

It would probably be better to have a default compression, but that's something that hadn't occured to me until about 14 seconds ago....

edit: So....

if [ ! $1 ]; then
echo "no compression specified (1-100)
assuming 90"
QUAL=90
else    
QUAL=$1
import -pause 5 -window root -quality $QUAL ${FILENAME}

Powered by Ikonboard 3.1.2a
Ikonboard © 2001 Jarvis Entertainment Group, Inc.