62637

How to get the picture size in pygame (python)

Question:

If I'm using an image and I want to know the image's size <strong>in the file</strong>.

There is a function to get <strong>the picture's</strong> height and width ?

EDIT: Of course I loaded the image to the program with pygame.image.load(PATH).

Answer1:

I believe you need to load the image as a Surface before you can get its width and height. You do that with foo = pygame.image.load(PATHNAME).

Then you can get the width and height by creating a Rectangle with foo.get_rect() and asking the rectangle.

Recommend

  • write text on image and show it to a imageview
  • Certain Arabic text gets incorrectly shown while other Arabic text gets showed normally?
  • How to change placeholder text in an autocomplete activity of android google place?
  • Memory error in python- how to use more memory
  • Can't delete or rename original file after resizing
  • Differences in dis-assembled C code of GCC and Borland?
  • D3 get axis values on zoom event
  • Using a canvas object in a thread to do simple animations - Java
  • How can I enlarge video fullscreen without the affected interface project in as3?
  • OpenGL 3.3 on Mac OSX El Capitan with LWJGL
  • Python urlparse: small issue
  • Change multiple background-images with jQuery
  • Algorithm for a smudge tool?
  • FileReader+canvas image loading problem
  • Ajax Loaded meta Tags
  • Android screen density dpi vs ppi
  • Fetching methods from BroadcastReceiver to update UI
  • How to set/get protobuf's extension field in Go?
  • DirectX11 ClearRenderTargetViewback with transparent buffer?
  • Change an a tag attribute in JavaScript based on screen width
  • Symfony2: How to get request parameter
  • How to show dropdown in excel using jrxml (jasper api)?
  • GridView Sorting works once only
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • File upload with ng-file-upload throwing error
  • WPF Applying a trigger on binding failure
  • NSLayoutConstraint that would pin a view to the bottom edge of a superview
  • Load html files in TinyMce
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • Free memory of cv::Mat loaded using FileStorage API
  • How get height of the a view with gone visibility and height defined as wrap_content in xml?
  • coudnt use logback because of log4j
  • Java static initializers and reflection
  • Setting background image for body element in xhtml (for different monitors and resolutions)
  • python draw pie shapes with colour filled
  • Checking variable from a different class in C#
  • Binding checkboxes to object values in AngularJs
  • Net Present Value in Excel for Grouped Recurring CF
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize
  • How to load view controller without button in storyboard?