{
  "post": {
    "tags": ["Image Processing"],
    "summary": "Get image color conversion",
    "description": "Converts an image to SVG format with specified color count or black/white conversion. This endpoint uses external APIs or Python scripts to process the image.\n\n**Authentication:**\n- Requires `API-KEY` header with the encryption key (UUID) returned from `/api/save-credentials`\n- The encryption key must have `colorConversion` credentials configured\n\n**Color Conversion Types:**\n- **Number (1-256):** Converts image to SVG with specified number of colors using external vectorization API\n- **'black_white':** Converts image to black and white using Python script, generates both SVG and PNG formats\n\n**File Structure:**\n- Converted images are saved to: `{mediaPath}/{original_dir}/{original_filename}/converted/{filename}_pd_{no_of_image_convert}_color.svg`\n- If the file already exists, it returns the cached version without reprocessing",
    "security": [
      {
        "ApiKeyAuth": []
      }
    ],
    "requestBody": {
      "required": true,
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "image_url": {
                "type": "string",
                "format": "uri",
                "description": "Full URL of the image to convert. Must contain '/media/' in the path.",
                "example": "https://example.com/media/productdesigner/imagecolor/sample.jpg"
              },
              "image_convert_type": {
                "type": "string",
                "enum": ["color"],
                "description": "Type of image conversion. Currently only 'color' is supported.",
                "example": "color"
              },
              "no_of_image_convert": {
                "oneOf": [
                  {
                    "type": "string",
                    "enum": ["black_white"],
                    "description": "Convert to black and white. Generates both SVG and PNG formats."
                  },
                  {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 256,
                    "description": "Number of colors for conversion (1-256). Uses external vectorization API."
                  }
                ],
                "description": "Color conversion specification. Either 'black_white' for black/white conversion or a number (1-256) for color count.",
                "example": 16
              }
            },
            "required": ["image_url", "image_convert_type", "no_of_image_convert"]
          }
        }
      }
    },
    "responses": {
      "200": {
        "summary": "Image converted successfully.",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "message": {
                  "type": "string",
                  "example": "Successfully Generated image"
                },
                "data": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": ["Success"],
                      "example": "Success"
                    },
                    "message": {
                      "type": "string",
                      "example": "Successfully Generated image"
                    },
                    "result": {
                      "type": "string",
                      "description": "JSON string containing the result data",
                      "example": "{\"original_image_url\":\"https://example.com/media/image.jpg\",\"generated_image_url\":\"https://example.com/media/image/converted/image_pd_16_color.svg\"}"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "400": {
        "summary": "Bad Request.",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "message": {
                  "type": "string",
                  "examples": ["Please send proper params.", "Invalid image URL format - must contain /media/"]
                },
                "data": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": ["Error"],
                      "example": "Error"
                    },
                    "message": {
                      "type": "string",
                      "example": "Please send proper params."
                    },
                    "result": {
                      "type": "string",
                      "example": ""
                    }
                  }
                }
              }
            }
          }
        }
      },
      "401": {
        "summary": "Unauthorized.",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "message": {
                  "type": "string",
                  "examples": [
                    "Encryption key missing. Please provide encryption key in API-KEY header.",
                    "Invalid encryption key format. Expected UUID format.",
                    "Failed to decrypt credentials. Invalid encryption key or corrupted credential file.",
                    "Credential not found. Please ensure credentials are saved and the correct encryption key is provided.",
                    "Color conversion credentials not configured for this encryption key. Please save color conversion credentials first."
                  ]
                }
              }
            }
          }
        }
      },
      "500": {
        "summary": "Internal Server Error.",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "message": {
                  "type": "string",
                  "example": "Failed to generate image"
                },
                "data": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": ["Error"],
                      "example": "Error"
                    },
                    "message": {
                      "type": "string",
                      "example": "Failed to generate image"
                    },
                    "result": {
                      "type": "string",
                      "example": ""
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
