Image Editing Toolset#
Generated byAIThis toolset provides tools for reading and creating image files within the current directory.
read_image_file#
Purpose: Reads the content of a specified image file in the current directory and returns it as a base64 encoded data URL string.
Parameters#
| Parameter | Type | Required | Description |
|---|---|---|---|
file_path |
String | Yes | The relative path to the image file to read. |
Success Case Example#
Input:
{
"file_path": "example.png"
}Output:
{
"file_path": "example.png",
"image_data": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
}Error Case Examples#
-
Missing File Path:
{ "error": "The required file_path was not specified" } -
File Does Not Exist:
{ "error": "The specified file 'example.png' does not exist." } -
Invalid File Type:
{ "error": "The specified file 'example.png' is not an image file." } -
Access Denied:
{ "error": "Access to the specified path 'example.png' is not allowed." } -
General Error:
{ "error": "An error occurred while reading the file: Permission denied" }
Notes#
- Supported image formats are PNG and JPEG.
- The tool ensures the file is within the current directory and is a valid image file.
create_image_file#
Purpose: Creates an image file from base64 encoded image data at the specified path. Ensures the file is created within the current directory and does not overwrite existing files.
Parameters#
| Parameter | Type | Required | Description |
|---|---|---|---|
file_path |
String | Yes | The relative path where the image file will be created. |
image_data |
String | Yes | The base64 encoded image data in the format of a data URL (data:<content_type>;base64,<data>). Supported content types are PNG and JPEG. |
Success Case Example#
Input:
{
"file_path": "new_image.png",
"image_data": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
}Output:
{
"message": "Image file 'new_image.png' created successfully."
}Error Case Examples#
-
Missing File Path:
{ "error": "The required file_path was not specified" } -
Missing Image Data:
{ "error": "The required image_data was not specified" } -
Invalid Data URL:
{ "error": "The provided image data is not a valid data URL." } -
Unsupported Format:
{ "error": "Unsupported or mismatched image format: image/gif. Detected format: image/png. Supported formats are PNG and JPEG." } -
File Already Exists:
{ "error": "The file 'new_image.png' already exists." } -
Access Denied:
{ "error": "Access to the specified path 'new_image.png' is not allowed." } -
General Error:
{ "error": "An error occurred while creating the image file: Permission denied" }
Notes#
- The tool ensures the file is created within the current directory and does not overwrite existing files.
- Supported image formats are PNG and JPEG.