Returns the width and height of an image stored in a file.
Another way to get the resolution of an image is to load it into a file cop and retrieve it. For example, this method could be approximately implemented as follows:
def imageResolution(image_file_name): file_cop = hou.node("/img/comp1").createNode("file") file_cop.setParm("filename1", image_file_name) resolution = (file_cop.xRes(), file_cop.yRes()) file_cop.destroy() return resolution
Note, however, that this method is faster than loading the image into Houdini and retrieving the resolution because it is much less disk intensive. It does not load the image data from disk, and instead only loads as much as necessary to retrieve the resolution.
Raises hou.OperationFailed if the image file does not exist or if it’s not an image file type supported by Houdini.
The following example retrieves the resolution of the default.pic file that ships with Houdini.
>>> hou.imageResolution(hou.findFile("pic/default.pic")) (512, 512)