From gnome-screenshot command line, how do you predefine the area?

12,625

It looks like there isn't such an option but you can control your mouse from command line using xdotool, so you can try to play with it:

(gnome-screenshot -a &); sleep 0.1 && xdotool mousemove 100 100 mousedown 1 mousemove 500 500 mouseup 1 

I use (cmd &) syntax to have command running in background (using just && here won't work because gnome-screenshot waits for input) and make small delay (try to experiment with values of sleep) to be sure that mouse won't be moving before it's ready. Then I use mousemove x y, mousedown 1 and mouseup 1 commands to simulate grabbing an area.

You should also check out more suited tool for getting screenshots which is import from ImageMagick:

import -window root ~/Pictures/img.png -crop 100x100+1100+1100
Share:
12,625
Tim
Author by

Tim

My name is Tim. I've graduated from the University of Nottingham with a First Class Computer Science BSc with Hons. In my spare time I do computer programming, often C or JavaScript, but also shell scripts, and answering questions on Stack Exchange. I used to spend most of my time on Ask Ubuntu; now I mostly browse the HNQ or Meta Stack Exchange. If you want to contact me it's [email protected] Do you need a reliable VPS? Try Digital Ocean. Sign up with this link for $10 free. One of my favourite sites is Kiva.org, a micro-funding organisation that allows people to lend money via the Internet to low-income entrepreneurs and students in over 80 countries. Kiva's mission is “to connect people through lending to alleviate poverty.” With just $25 you can make a difference - and 99% of loans are paid back in full - so you can lend again and again!

Updated on September 18, 2022

Comments

  • Tim
    Tim over 1 year

    So gnome-screenshot has the following options:

    tim@Hairy14:~$ gnome-screenshot --help
    Usage:
      gnome-screenshot [OPTION…] Take a picture of the screen
    
    Help Options:
      -h, --help                     Show help options
      --help-all                     Show all help options
      --help-gtk                     Show GTK+ Options
    
    Application Options:
      -c, --clipboard                Send the grab directly to the clipboard
      -w, --window                   Grab a window instead of the entire screen
      -a, --area                     Grab an area of the screen instead of the entire screen
      -b, --include-border           Include the window border with the screenshot
      -B, --remove-border            Remove the window border from the screenshot
      -p, --include-pointer          Include the pointer with the screenshot
      -d, --delay=seconds            Take screenshot after specified delay [in seconds]
      -e, --border-effect=effect     Effect to add to the border (shadow, border, vintage or none)
      -i, --interactive              Interactively set options
      -f, --file=filename            Save screenshot directly to this file
      --version                      Print version information and exit
      --display=DISPLAY              X display to use
    

    The one I'm interested in is -a.

    If it run it, the following happens, I can click and drag anywhere on the screen and it saves an image, of the are I chose.

    I have the short cut Alt+Shift+4 set up for this.

    But what I want is a predefined area, somehting allong the lines of this:

    gnome-screenshot -a 400x500+100x100
    

    (i.e. 400 down, 500 in and 100x100 area).

    Is this possible, and is there a command to do this?

    NB: I could use the image cropping tool convert -crop like this:

    convert -crop 100x100+50+50 Pictures/Screenshot.png Pictures/Screenshot-cropped.png
    

    but I would like it if it was built in, as cropping a full print screen makes it blurry...