#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2004
    Posts
    37
    Rep Power
    10

    Python Image Library


    Code:
    import sys
    import ImageGrab
    im = ImageGrab.grab(0,0,5,10)
    print im.size
    im.show()
    Alright, I've got it working...Kinda.
    when I take im = Image.Grab.grab(0,0,5,10) and change that to just (0) it works. I did research on the way to set it up and it is supposed to be set up as following: (x,y, width, height). What am I doing wrong. I have PIL installed and can't figure anything out. Your help is greatly appreciated.

    Thank You
  2. #2
  3. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Your problem, as I see it is that ImageGrab.grab() takes one argument and you are trying to pass it four . From the PIL documentation, a box is a Tuple of four values so I suspect that you need to do something like this:

    Code:
    import sys
    import ImageGrab
    im = ImageGrab.grab((0, 0, 5, 10))
    print im.size
    im.show()
    Obviously I can't test this myself since I'm working on a Mac and ImageGrab.grab() only works with Windows right now .

    Hope this helps,

    Mark.
    programming language development: www.netytan.com Hula

  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2004
    Posts
    37
    Rep Power
    10
    Works Like a charm.
    Thanks!
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2004
    Location
    california
    Posts
    53
    Rep Power
    10
    Hey, Im new at this and I dont know what im doing wrong. I put the exact thing it says to put in for a screenshot but every time it does this:

    >>> import sys
    >>> import ImageGrab
    Traceback (most recent call last):
    File "<stdin>", line 1, in ?
    ImportError: No module named ImageGrab
    >>>




    What should I do with the "import ImageGrab?"
  8. #5
  9. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Since PIL (the Python Imaging Library) doesn't come with the standard Python distribution you'll need to install it yourself. You can download the latest version as an exe (Windows installer) from here:

    http://www.pythonware.com/products/pil/index.htm

    You might also want to read though the "Imagine Python" article in Devsheds Python section:

    http://www.devshed.com/c/a/Python/Imagine-Python/

    Have fun,

    Mark.
    programming language development: www.netytan.com Hula

  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2004
    Location
    california
    Posts
    53
    Rep Power
    10
    The PIP file from the website does not work for python 2.4 .I downloaded python 2.4, and I am wondering is there any way that I can get the file for (python 2.4). Or do I have to download python 2.3?
  12. #7
  13. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    We get this after every major release , unfortunately you only have two choices - wait for the guys to test, build and add a compatible binary or stick with 2.3 like you mentioned; not a bad idea since it's going to take a little time for all the third party modules to catch up anyway. (This usually doesn't take too long though).

    Still, If you can't wait to play with the new stuff in Python 2.4 then just take the plunge and have some fun while you're waiting .

    Mark.
    programming language development: www.netytan.com Hula

  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2004
    Location
    california
    Posts
    53
    Rep Power
    10

    Question


    alright thanks:
    I just downloaded version 2.3.4 so that I could get the Image Library. I've tried the ImageGrab and it works great.I was wondering if there is anyway for you to abtract an image using something like "Paint program" and paste the abstracted image on an internet game so that the picture would be there but not really the item. Am I too confusing?

IMN logo majestic logo threadwatch logo seochat tools logo