How do I get the height and width (in pixels) of an image that's been imported in Blender?
bpy.data.images['myImage'].???
How do I get the height and width (in pixels) of an image that's been imported in Blender?
bpy.data.images['myImage'].???
You can use the size
property to get the X and Y dimensions of an image:
width, height = bpy.data.images['myImage'].size
# the variables width and height will now contain the pixel size
size
property is simply an array, you could access the values like bpy.data.images['myImage'].size[0]
and bpy.data.images['myImage'].size[1]
. However, I tend to find the given answer to be more Pythonic. See note.nkmk.me/en/python-tuple-list-unpack for a deeper explanation
$\endgroup$
Commented
May 15, 2020 at 15:33