Image Operations¶
Operations for managing images.
Bases: StashClientProtocol
Mixin for image-related client methods.
Functions¶
find_image
async
¶
find_image(id: str) -> Image | None
Find an image by its ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str
|
The ID of the image to find |
required |
Returns:
| Type | Description |
|---|---|
Image | None
|
Image object if found, None otherwise |
find_images
async
¶
find_images(
filter_: dict[str, Any] | None = None,
image_filter: dict[str, Any] | None = None,
q: str | None = None,
) -> FindImagesResultType
Find images matching the given filters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filter_
|
dict[str, Any] | None
|
Optional general filter parameters: - q: str (search query) - direction: SortDirectionEnum (ASC/DESC) - page: int - per_page: int - sort: str (field to sort by) |
None
|
image_filter
|
dict[str, Any] | None
|
Optional image-specific filter |
None
|
q
|
str | None
|
Optional search query (alternative to filter_["q"]) |
None
|
Returns:
| Type | Description |
|---|---|
FindImagesResultType
|
FindImagesResultType containing: - count: Total number of matching images - images: List of Image objects |
create_image
async
¶
Create a new image in Stash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
Image
|
Image object with the data to create. Required fields: - title: Image title |
required |
Returns:
| Type | Description |
|---|---|
Image
|
Created Image object with ID and any server-generated fields |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the image data is invalid |
TransportError
|
If the request fails |
update_image
async
¶
Update an existing image in Stash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
Image
|
Image object with updated data. Required fields: - id: Image ID to update Any other fields that are set will be updated. Fields that are None will be ignored. |
required |
Returns:
| Type | Description |
|---|---|
Image
|
Updated Image object with any server-generated fields |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the image data is invalid |
TransportError
|
If the request fails |
image_destroy
async
¶
Delete an image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_data
|
ImageDestroyInput | dict[str, Any]
|
ImageDestroyInput object or dictionary containing: - id: Image ID to delete (required) - delete_file: Whether to delete the image's file (optional, default: False) - delete_generated: Whether to delete generated files (optional, default: True) |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the image was successfully deleted |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the image ID is invalid |
TransportError
|
If the request fails |
images_destroy
async
¶
Delete multiple images.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_data
|
ImagesDestroyInput | dict[str, Any]
|
ImagesDestroyInput object or dictionary containing: - ids: List of image IDs to delete (required) - delete_file: Whether to delete the images' files (optional, default: False) - delete_generated: Whether to delete generated files (optional, default: True) |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the images were successfully deleted |
Raises:
| Type | Description |
|---|---|
ValueError
|
If any image ID is invalid |
TransportError
|
If the request fails |
bulk_image_update
async
¶
bulk_image_update(
input_data: BulkImageUpdateInput | dict[str, Any],
) -> list[Image]
Bulk update images.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_data
|
BulkImageUpdateInput | dict[str, Any]
|
BulkImageUpdateInput object or dictionary containing: - ids: List of image IDs to update (optional) - And any fields to update (e.g., organized, rating100, etc.) |
required |
Returns:
| Type | Description |
|---|---|
list[Image]
|
List of updated Image objects |
Examples:
Mark multiple images as organized:
Add tags to multiple images:
images_update
async
¶
images_update(
updates: list[ImageUpdateInput] | list[dict[str, Any]],
) -> list[Image]
Update multiple images with individual update data.
This is different from bulk_image_update which applies the same updates to all images. This method allows updating each image with different values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
updates
|
list[ImageUpdateInput] | list[dict[str, Any]]
|
List of ImageUpdateInput objects or dictionaries, each containing: - id: Image ID to update (required) - Any other fields to update for that specific image |
required |
Returns:
| Type | Description |
|---|---|
list[Image]
|
List of updated Image objects (may contain None for failed updates) |
Examples:
Update multiple images with different values:
from stash_graphql_client.types import ImageUpdateInput
updates = [
ImageUpdateInput(id="1", title="First Image", organized=True),
ImageUpdateInput(id="2", title="Second Image", rating100=90),
]
images = await client.images_update(updates)
Using dictionaries: