Alex Rivera | Logout

Take a screenshot via a Python script on Linux

Asked 2008-09-16T05:44:54.840
96

I want to take a screenshot via a python script and unobtrusively save it.

I'm only interested in the Linux solution, and should support any X based environment.

Edit
Report

1 Answer

18

I have a wrapper project (pyscreenshot) for scrot, imagemagick, pyqt, wx and pygtk. If you have one of them, you can use it. All solutions are included from this discussion.

Install:

easy_install pyscreenshot

Example:

import pyscreenshot as ImageGrab

# fullscreen
im=ImageGrab.grab()
im.show()

# part of the screen
im=ImageGrab.grab(bbox=(10,10,500,500))
im.show()

# to file
ImageGrab.grab_to_file('im.png')
answered 2011-10-19T06:44:20.560

Your Answer