Exemple #1
0
def read_texture(filename, attrs=None):
    """Load a ``vtkTexture`` from an image file."""
    filename = os.path.abspath(os.path.expanduser(filename))
    try:
        # initialize the reader using the extension to find it
        reader = get_reader(filename)
        image = standard_reader_routine(reader, filename, attrs=attrs)
        return pyvista.image_to_texture(image)
    except KeyError:
        # Otherwise, use the imageio reader
        pass
    return pyvista.numpy_to_texture(imageio.imread(filename))
Exemple #2
0
def read_texture(filename, attrs=None):
    """Load a ``vtkTexture`` from an image file."""
    filename = os.path.abspath(os.path.expanduser(filename))
    try:
        # initialize the reader using the extension to find it
        reader = get_reader(filename)
        image = standard_reader_routine(reader, filename, attrs=attrs)
        if image.n_points < 2:
            raise RuntimeError("Problem reading the image with VTK.")
        return pyvista.image_to_texture(image)
    except (KeyError, RuntimeError):
        # Otherwise, use the imageio reader
        pass
    import imageio
    return pyvista.numpy_to_texture(imageio.imread(filename))