With the Blender Python API we can very easily resize images, both common and .hdr or .exr environment maps. Any image loaded to Blender can be resized with the scale function.
Once we’ve loaded an image into Blender, from the Image Editor, or in any other way, we can view its dimensions through the size property.
We can refer to the image by name through the bpy.data.images structure.
1 2 |
bpy.data.images['_image_name_.exr'].size[:] # (2048, 1024) |
To resize the image, let’s call the scale method, with the required width and height in its parameters.
For example, to reduce the existing image by half:
1 |
bpy.data.images['_image_name_.exr'].scale(1024, 512) |
We can verify that the size of an image has changed by recalling its size property.
1 2 |
bpy.data.images['studio_small_03.exr'].size[:] # (1024, 512) |
To save the resized image, just press the alt + shift + s key combination in the Image Editor area.