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

command linegnomescreenshot

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 100×100 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…

Best Answer

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