Image Editing Toolset#

Generated byAI

This 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#

  1. Missing File Path:

    {
      "error": "The required file_path was not specified"
    }
  2. File Does Not Exist:

    {
      "error": "The specified file 'example.png' does not exist."
    }
  3. Invalid File Type:

    {
      "error": "The specified file 'example.png' is not an image file."
    }
  4. Access Denied:

    {
      "error": "Access to the specified path 'example.png' is not allowed."
    }
  5. 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#

  1. Missing File Path:

    {
      "error": "The required file_path was not specified"
    }
  2. Missing Image Data:

    {
      "error": "The required image_data was not specified"
    }
  3. Invalid Data URL:

    {
      "error": "The provided image data is not a valid data URL."
    }
  4. Unsupported Format:

    {
      "error": "Unsupported or mismatched image format: image/gif. Detected format: image/png. Supported formats are PNG and JPEG."
    }
  5. File Already Exists:

    {
      "error": "The file 'new_image.png' already exists."
    }
  6. Access Denied:

    {
      "error": "Access to the specified path 'new_image.png' is not allowed."
    }
  7. 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.