Skip to content

npxpy.resources.Image

Bases: Resource

A class to represent an image resource.

Source code in npxpy/resources.py
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
class Image(Resource):
    """
    A class to represent an image resource.
    """

    def __init__(self, file_path: str, name: str = "image"):
        """
        Initialize the image resource with the specified parameters.

        Parameters:
            file_path (str): Path where the image is stored.
            name (str, optional): Name of the image resource. Defaults to 'image'.
        """
        # Ensure the file_path is valid
        if not os.path.isfile(file_path):
            raise FileNotFoundError(f"Image file not found: {file_path}")

        super().__init__(
            resource_type="image_file", name=name, file_path=file_path
        )

__init__(file_path, name='image')

Initialize the image resource with the specified parameters.

Parameters:

Name Type Description Default
file_path str

Path where the image is stored.

required
name str

Name of the image resource. Defaults to 'image'.

'image'
Source code in npxpy/resources.py
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
def __init__(self, file_path: str, name: str = "image"):
    """
    Initialize the image resource with the specified parameters.

    Parameters:
        file_path (str): Path where the image is stored.
        name (str, optional): Name of the image resource. Defaults to 'image'.
    """
    # Ensure the file_path is valid
    if not os.path.isfile(file_path):
        raise FileNotFoundError(f"Image file not found: {file_path}")

    super().__init__(
        resource_type="image_file", name=name, file_path=file_path
    )