Posted by & filed under Coding.

Thanks to Pygame, there’s a quick and easy method to get the dimensions of an image. You just have to load it into a Surface and use the Surface methods get_height() and get_width().

import pygame

img = pygame.image.load("filename.png")

print "Width = " + `img.get_width()`
print "Height = " + `img.get_height()`

Leave a Reply

Your email address will not be published. Required fields are marked *