pyvista.read_texture

Contents

pyvista.read_texture#

read_texture(filename: str | Path, progress_bar: bool = False) Texture[source]#

Load a texture from an image file.

Will attempt to read any file type supported by vtk, however if it fails, it will attempt to use imageio to read the file.

Parameters:
filenamestr

The path of the texture file to read.

progress_barbool, default: False

Optionally show a progress bar.

Returns:
pyvista.Texture

PyVista texture object.

Examples

Read in an example jpg map file as a texture.

>>> from pathlib import Path
>>> import pyvista as pv
>>> from pyvista import examples
>>> Path(examples.mapfile).name
'2k_earth_daymap.jpg'
>>> texture = pv.read_texture(examples.mapfile)
>>> type(texture)
<class 'pyvista.plotting.texture.Texture'>