PIL Question

Chris Rebert clp2 at rebertia.com
Sun May 1 21:00:26 EDT 2011


On Sun, May 1, 2011 at 1:50 PM, PyNewbie <ryan.morrone at gmail.com> wrote:
> Hi,
>
> I'm new with Python and PIL. I have a very simple question regarding an image capture function I'm attempting.
>
> Here is the code:
>
>
>>>> from PIL import ImageGrab
>>>> ImageGrab.grab().save("screen_capture.jpg", "JPEG")
>
> Question: I can't seem to find the captured image, where does it go?  The python Shell IDE does not display an error, and the code appears to have been processed.
>
> Additional Info: I'm using Python 2.6, and PIL 1.1.7 for Python 2.6 Windows.

I would think to a file named "screen_capture.jpg" in the current
working directory. What that is for IDLE, I don't know. You can
determine what folder that is by running this in your Python shell:

from os import getcwd
print(getcwd())

Also, I would suggest using absolute file paths in the future, rather
than relative ones; e.g. "C:/Documents and Settings/Your
username/Desktop/screen_capture.jpg" rather than just
"screen_capture.jpg".

Cheers,
Chris



More information about the Python-list mailing list