image height and width

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Memozio
    New Member
    • Sep 2007
    • 14

    image height and width

    Hi,
    any suggestions on how to get width and height of an image from an image file? And further, how to get the color value at any point of the image?
  • bartonc
    Recognized Expert Expert
    • Sep 2006
    • 6478

    #2
    Originally posted by Memozio
    Hi,
    any suggestions on how to get width and height of an image from an image file? And further, how to get the color value at any point of the image?
    That will depend entirely on the type of image and the tools that you are using.
    PIL & Tkinter? wxPython? Other? Working with gif, tiff, png, jpeg, etc????

    Comment

    • Memozio
      New Member
      • Sep 2007
      • 14

      #3
      Hey,
      I'm using .png image files. I'm working with FrogLogic configured to use Python language.I've already learned that I can use PIL for that, for example:

      from PIL import image
      im=Image.image( "image.png" )
      pring im.size

      and it will return tuple of the format (width, height). I'm wondering if I can somehow get those values in separate statements so I can store them for future use in my script!?

      Comment

      • bartonc
        Recognized Expert Expert
        • Sep 2006
        • 6478

        #4
        Originally posted by Memozio
        Hey,
        I'm using .png image files. I'm working with FrogLogic configured to use Python language.I've already learned that I can use PIL for that, for example:

        from PIL import image
        im=Image.image( "image.png" )
        pring im.size

        and it will return tuple of the format (width, height). I'm wondering if I can somehow get those values in separate statements so I can store them for future use in my script!?
        [CODE=python]width, height = im.size[/CODE]will "unpack" the tuple. This method is used often, but the tuple size must match the variable assignments or it will throw an exception.

        Comment

        • Memozio
          New Member
          • Sep 2007
          • 14

          #5
          Originally posted by bartonc
          [CODE=python]width, height = im.size[/CODE]will "unpack" the tuple. This method is used often, but the tuple size must match the variable assignments or it will throw an exception.

          Thank you, Mr. Barton)))
          it really helped me!

          Comment

          • bartonc
            Recognized Expert Expert
            • Sep 2006
            • 6478

            #6
            Originally posted by Memozio
            Thank you, Mr. Barton)))
            it really helped me!
            You are quite welcome. That's what we are here for.

            Keep posting,
            Barton

            Comment

            Working...