Search code examples
pythonscreenshotgnome

Taking screenshot from a python script by selecting the area


I saw that post (that is really helpful : Take a screenshot via a python script. [Linux]) about taking a screenshot from python. It works well but I'd like to have the same behavior as gnome-screenshot : having the possibility to choose between :

  • Capturing the whole desktop
  • Capturing an active window
  • Capturing an area

Is there a way to do this in python, or, eventually, to use the gnome-screenshot application to do it, and then getting the file ?

I tried to find the perfect command line for gnome-screenshot to be launched without asking where to save the screenshot after by giving the path at the call, but I can't find it.

Thanks for your help!


Solution

  • If you are not limited to using using gnome-screenshot specifically, ImageMagick's import command can save directly to file without an interactive prompt.

    See here for details: http://www.imagemagick.org/script/import.php

    In addition to the command line interface, there is also a Python API.