Register
It is currently Wed Oct 22, 2014 9:02 pm

One-click screenshots with ImageMagick


All times are UTC - 6 hours


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Mon Dec 04, 2006 7:27 pm   

Joined: Wed Sep 06, 2006 12:19 pm
Posts: 54
Location: Covington, WA
Just found a script that uses ImageMagick's 'import' command to take screenshots.............It doesn't have all the bells and whistles, such as a delay option, but is handy for quickly taking screenshots........

I've been reading up on ImageMagick tips and tricks when I found this handy script, which I modified by refining the command with options (the original script didn't use any options for the 'import' command).......

The original script can be found at Web Design Tips: How to Take a Screenshot in Linux (Ubuntu), under the section "How to Take a Screenshot in GNOME With One Click".......This tip shows how to set up the script by creating a launch button from the GNOME panel.......

This can also be adapted to other window managers/desktops, which I'll describe how to set it up in KDE
  1. First, copy-n-paste the code below and save to file. I chose 'imss' (ImageMagick ScreenShot) as a filename. Save it somewhere in your PATH, such as '/usr/local/bin' and make it executable (chmod +x /usr/local/bin/imss).
  2. After saving to a file, right-click on the "K Menu" button in the kicker panel at the bottom left corner (the button with a "K" on it) and click on "Menu Editor"
  3. In the editor, right-click on the "Graphics" menu folder and choose "New Item" (not "New Submenu")
  4. In the dialog box that pops up, choose a menu name, such as "IMSS" or whatever you want to call it, and click 'OK'
  5. Then, at the right side of the menu editor, fill in the required info. "Name" should already be filled in.
  6. The next required line is the "Command" text box, which is the name of the script.

    The rest of the text boxes are optional, although I added "ImageMagick Screenshot" in the comment text box, and unchecked the "Enable launch feedback" line right below the "Command" text box.

    The launch feedback is what determines if a bouncing or blinking image is displayed next to the cursor when the application starts up. For this menu entry, it will continue on until it times out, which is very annoying (at least for me).

    Do not place a check mark in the "Run in terminal" box. This will cause a Konsole window to appear, which does not go away until you manually close the window.
  7. Close the Menu Editor when you are done.
  8. Now right-click on any existing launch button in the kicker panel, at the bottom of the desktop, where you want to place the new launch button for the newly created screenshot menu entry.
  9. After right-clicking on the button, highlight "Panel Menu", and a submenu will pop up. In this submenu, highlight "Add Application to Panel" and another submenu pops up. In this submenu, highlight the "Graphics" entry and in the next submenu click on the menu entry you just created. This will place the new launch button to the left of the existing button you used.

    To sum up this step, the order is Panel Menu -> Add Application to Panel -> Graphics -> [Your new menu entry].

That's it. Now, you can click on the launch button and create screenshots to your heart's content with a single click of the mouse button...... ;-)

Code:
#!/bin/bash
################################################################################
#
# imss - ImageMagick ScreenShot utility.  Takes a screenshot with ImageMagick's
#        'import' command and saves to user's Desktop.  From the 'import'
#        manpage:
#            import - saves any visible window on an X server and outputs
#            it as an image file. You can capture a single window, the
#            entire screen, or any rectangular portion of the screen
#
#
# Modified from a script found at Web Design Tips, under the section "How to
# Take a Screenshot in GNOME With One Click" on the page titled "How to Take a
# Screenshot in Linux (Ubuntu)"
#  <http://tips.webdesign10.com/how-to-take-a-screenshot-on-ubuntu-linux>
#
# To use, simply invoke the script.  The mouse pointer will change to a
# crosshair, which can be used to outline a rectangular section by left-clicking
# the mouse and dragging over the desired area on the desktop.  To take a
# snapshot of a whole window (including the desktop's themed window border),
# simply click on the desired window app without dragging the mouse.  Two beeps
# will sound, one at the start of the screenshot creation and one immediately
# after the image is created.  For small screenshots (or very fast machines),
# it will sound like a double-beep.
#
################################################################################

# We'll create an unusual filename based on the number of seconds since
# "1970-01-01 00:00:00 UTC" so we don't accidentally overwrite another screen-
# shot.  This will also allow screenshots to be automatically stored in the
# order they were taken:
import -frame -strip -quality 80 "$HOME/Desktop/screenshot-$(date +%s).png"

exit 0

################################################################################
##
## Explanation of options used:
##    -strip  strip the image of any profiles or comments
##
##
##    -frame  include the X window frame in the imported image
##
##
##  -quality  JPEG/MIFF/PNG compression level
##
##            For the MNG and PNG image formats, the quality value sets the zlib
##            compression level (quality / 10) and filter-type (quality % 10).
##            Compression levels range from 0 (fastest compression) to 100 (best
##            but slowest). For compression level 0, the Huffman-only strategy is
##            used, which is fastest but not necessarily the worst compression.
##
##            The default quality is 75, which means nearly the best compression
##            with adaptive filtering. The quality setting has no effect on the
##            appearance of PNG and MNG images, since the compression is always
##            lossless. (NOTE: Value of 80 seems to be the best compression
##            with adaptive filtering, as values from 81-89 have a larger file
##            size).
##
################################################################################



Last edited by thegeekster on Tue Dec 05, 2006 9:48 am, edited 1 time in total.

Top
 Profile  
 PostPosted: Tue Dec 05, 2006 9:29 am   

Joined: Wed Sep 06, 2006 12:19 pm
Posts: 54
Location: Covington, WA
Added more info in step 1, which is to save the script in your PATH and make it executable.......Also removed the '-screen' option, since it seemed like it really didn't make a difference in behavior........ :-)


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP