Houdini 20.5 hapi

hapi.extractImageToFile function

Extract a rendered image to a file.

Note that you must call hapi.renderTextureToImage first for this method call to make sense.

Usage

extractImageToFile(session: hapi.Session, material_node_id: int, image_file_format_name: str, image_planes: str, destination_folder_path: str, destination_file_name: str) → int

Extract a rendered image to a file.

session

The session of Houdini you are interacting with. See hapi.Session for more on sessions. Pass None to just use the default in-process session.

material_node_id

The material node id.

image_file_format_name

The image file format name you wish the image to be extracted as. You can leave this parameter None to get the image in the original format if it comes from another texture file or in the default HAPI format, which is hapi.DEFAULT_IMAGE_FORMAT_NAME if the image is generated.

You can get some of the very common standard image file format names from HAPI_Common.h under the “Defines” section.

You can also get a list of all supported file formats (and the exact names this parameter expects) by using hapi.getSupportedImageFileFormats. This list will include custom file formats you created via custom DSOs (see HDK docs about IMG_Format). You will get back a list of hapi.ImageFileFormat. This parameter expects the hapi.ImageFileFormat.nameSH of a given image file format.

image_planes

The image planes you wish to extract into the file. Multiple image planes should be separated by spaces.

destination_folder_path

The folder where the image file should be created.

destination_file_name

Optional parameter to overwrite the name of the extracted texture file. This should NOT include the extension as the file type will be decided by the hapi.ImageInfo you can set using hapi.setImageInfo. You still have to use destination_file_path to get the final file path.

Pass in None to have the file name be automatically generated from the name of the material SHOP node, the name of the texture map parameter if the image was rendered from a texture, and the image plane names specified.

Returns destination_file_path as a int.

hapi