Find the answer to your Linux question:
Results 1 to 7 of 7
Like Tree2Likes
  • 1 Post By atreyu
  • 1 Post By oz
Hello, Could you please recommend me a command line program for taking screenshots that allows the specification (as command line arguments) of the coordinates on screen and size of region ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Oct 2012
    Posts
    3

    command line screenshot program


    Hello,
    Could you please recommend me a command line program for taking screenshots that allows the specification (as command line arguments) of the coordinates on screen and size of region to be included in screenshot. All programs that I know of (like Gnome-screenshot can not take screen coordinates as parameters, they only allow interactive selection of region).
    Many thanks

  2. #2
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    Hello and welcome,

    You can try the ImageMagick program. It is great for manipulating images on the command line. You'd try the import command, which comes with it:

    Code:
    import blah.jpg
    There are tons of options you can use with it, though i'm not sure about specifying exact coordinates. i know that you can specify a particular window (by it's X id, e.g.).

    There is also xwd and xv, but those seem to have gone the way of the dodo.
    sk78 likes this.

  3. #3
    oz
    oz is offline
    forum.guy
    Join Date
    May 2004
    Location
    arch linux
    Posts
    18,733
    Quote Originally Posted by sk78 View Post
    Could you please recommend me a command line program for taking screenshots that allows the specification (as command line arguments) of the coordinates on screen and size of region to be included in screenshot.
    Hello and welcome!

    In addition to atreyu's recommendation above, you can take a look at scrot to see if it will suit your needs. It's lighterweight than imagemagick but quite powerful. Note that I've not used it for shots with specific screen coordinates, so can't say right off hand if it will meet that need.

    Do let us know if either of the above recommendations work for you.
    sk78 likes this.
    oz

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined!
    Join Date
    Oct 2012
    Posts
    3
    Many thanks for your replies. I've looked at ImageMagick and Scrot but neither seem to have an option for specifying coordinates of region to capture, only id of window.
    I think there might be a way using ffmpeg. For instance:

    ffmpeg -f x11grab -s 660x468 -r 1 -t 1 -i :0.0+756,222 screenshot.jpg

    where -s 660x468 is size in pixels -r 1 is frame rate -t 1 is time (seconds) and -i :0.0+756,222 (0.0 es display screen number of your X11 server and 756 is the x-offset and 222 the y-offset)
    This is for capturing desktop video but setting -r and -t to 1, it should just capture one image.

    Please let me know if you find an easier way, though.

  6. #5
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    Quote Originally Posted by sk78 View Post
    ffmpeg -f x11grab -s 660x468 -r 1 -t 1 -i :0.0+756,222 screenshot.jpg

    where -s 660x468 is size in pixels -r 1 is frame rate -t 1 is time (seconds) and -i :0.0+756,222 (0.0 es display screen number of your X11 server and 756 is the x-offset and 222 the y-offset)
    This is for capturing desktop video but setting -r and -t to 1, it should just capture one image.

    Please let me know if you find an easier way, though.
    i'd say you found a darn good solution. the only thing i would have suggested is the -vframes 1 option to ffmpeg which limits the number of frames to record to one, but i'm not sure you need it.

  7. #6
    Just Joined!
    Join Date
    Oct 2012
    Posts
    3
    In fact you were right. It is possible in ImageMagick using the crop option. For instance:

    Code:
    import -window root -crop 660x480+756+222 screenshot.jpg

  8. #7
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    Quote Originally Posted by sk78 View Post
    In fact you were right. It is possible in ImageMagick using the crop option. For instance:

    Code:
    import -window root -crop 660x480+756+222 screenshot.jpg
    I've never used crop before, good find, and thanks for sharing!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •