Other Help Topics :: image-magick screenshot



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"

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.

Outstanding...excellent

Great job guys!

Brian
AwPhuch

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}


original here.