Skip to main content
Glama

crop_image

Crop an image

Extract a rectangular region from an image, in one of three mutually exclusive modes. Manual: give the top-left corner (x, y) and dimensions (width, height) in pixels. Smart crop: give 'gravity' (attention, entropy, centre) plus width and height; the window is picked automatically, clamped to the source if the target is larger. Trim: set 'trim: true' (optional 'threshold') to remove a uniform background border via content detection; the applied rect is reported in X-Pictomancer-Trim-* headers. Optional enhancement modifiers: denoise (1-3), equalize, sharpen (applied denoise -> equalize -> op -> sharpen).

Responses:

200: Processed image binary (Success Response) Content-Type: application/json Content-Type: image/jpeg

Example Response:

"string"

Content-Type: image/png

Example Response:

"string"

Content-Type: image/webp

Example Response:

"string"

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
xNoLeft edge of the crop rectangle in pixels. Manual mode only.
yNoTop edge of the crop rectangle in pixels. Manual mode only.
trimNoTrim mode: removes a uniform background border via content detection. Mutually exclusive with x/y/width/height/gravity.
widthNoWidth of the crop rectangle in pixels. Required in manual and gravity modes.
formatNoOutput format: jpeg, png, webp, tiff, gif, or avif. If omitted, the original format is preserved.
heightNoHeight of the crop rectangle in pixels. Required in manual and gravity modes.
sourceYesImage source: a public URL (https://...) or a base64-encoded string (optionally as a data URI like data:image/png;base64,...).
autorotNoApply EXIF orientation before cropping. Opt-in; default false, which preserves current byte-for-byte behavior.
denoiseNoMedian denoise before cropping: radius 1-3 (window 3x3 to 7x7). Opt-in; no surcharge.
gravityNoSmart-crop mode: picks the window automatically. One of ('attention', 'entropy', 'centre'). Requires width and height; mutually exclusive with x/y and trim. A target larger than the source clamps to the source size.
sharpenNoUnsharp-mask sharpen after cropping (libvips defaults). Opt-in.
deliveryNo
equalizeNoAuto-contrast (histogram equalisation of the value channel; hue and saturation preserved) before cropping. Opt-in.
thresholdNoTrim sensitivity (must be positive; default 10.0). Only valid together with trim: true.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changed
    • addedInput schema / properties / denoise
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "integer"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "description": "Median denoise before cropping: radius 1-3 (window 3x3 to 7x7). Opt-in; no surcharge.",
      +  "title": "denoise",
      +  "type": "integer"
      +}
    • addedInput schema / properties / equalize
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "boolean"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "description": "Auto-contrast (histogram equalisation of the value channel; hue and saturation preserved) before cropping. Opt-in.",
      +  "title": "equalize",
      +  "type": "boolean"
      +}
    • addedInput schema / properties / sharpen
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "boolean"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "description": "Unsharp-mask sharpen after cropping (libvips defaults). Opt-in.",
      +  "title": "sharpen",
      +  "type": "boolean"
      +}
  2. Changed13 schema fields changed
    • addedInput schema / properties / autorot
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "boolean"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "description": "Apply EXIF orientation before cropping. Opt-in; default false, which preserves current byte-for-byte behavior.",
      +  "title": "autorot",
      +  "type": "boolean"
      +}
    • addedInput schema / properties / gravity
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "description": "Smart-crop mode: picks the window automatically. One of ('attention', 'entropy', 'centre'). Requires width and height; mutually exclusive with x/y and trim. A target larger than the source clamps to the source size.",
      +  "title": "gravity",
      +  "type": "string"
      +}
    • addedInput schema / properties / height / anyOf
      Added value: +[
      +  {
      +    "type": "integer"
      +  },
      +  {
      +    "type": "null"
      +  }
      +]
    • changedInput schema / properties / height / description
      Previous value: -"Height of the crop rectangle in pixels."New value: +"Height of the crop rectangle in pixels. Required in manual and gravity modes."
    • addedInput schema / properties / threshold
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "number"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "description": "Trim sensitivity (must be positive; default 10.0). Only valid together with trim: true.",
      +  "title": "threshold",
      +  "type": "number"
      +}
    • addedInput schema / properties / trim
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "boolean"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "description": "Trim mode: removes a uniform background border via content detection. Mutually exclusive with x/y/width/height/gravity.",
      +  "title": "trim",
      +  "type": "boolean"
      +}
    • addedInput schema / properties / width / anyOf
      Added value: +[
      +  {
      +    "type": "integer"
      +  },
      +  {
      +    "type": "null"
      +  }
      +]
    • changedInput schema / properties / width / description
      Previous value: -"Width of the crop rectangle in pixels."New value: +"Width of the crop rectangle in pixels. Required in manual and gravity modes."
    • addedInput schema / properties / x / anyOf
      Added value: +[
      +  {
      +    "type": "integer"
      +  },
      +  {
      +    "type": "null"
      +  }
      +]
    • changedInput schema / properties / x / description
      Previous value: -"Left edge of the crop rectangle in pixels."New value: +"Left edge of the crop rectangle in pixels. Manual mode only."
    • addedInput schema / properties / y / anyOf
      Added value: +[
      +  {
      +    "type": "integer"
      +  },
      +  {
      +    "type": "null"
      +  }
      +]
    • changedInput schema / properties / y / description
      Previous value: -"Top edge of the crop rectangle in pixels."New value: +"Top edge of the crop rectangle in pixels. Manual mode only."
    • changedInput schema / required
      Previous value: -[
      -  "source",
      -  "x",
      -  "y",
      -  "width",
      -  "height"
      -]New value: +[
      +  "source"
      +]
  3. Changed1 schema field changed
    • changedInput schema / properties / format / description
      Previous value: -"Output format: jpeg, png, webp, tiff, or gif. If omitted, the original format is preserved."New value: +"Output format: jpeg, png, webp, tiff, gif, or avif. If omitted, the original format is preserved."
  4. Changed1 schema field changed
    • changedInput schema / properties / delivery / oneOf
      Previous value: -[
      -  {
      -    "additionalProperties": false,
      -    "properties": {
      -      "mode": {
      -        "const": "inline",
      -        "default": "inline",
      -        "title": "Mode",
      -        "type": "string"
      -      }
      -    },
      -    "title": "InlineDelivery",
      -    "type": "object"
      -  },
      -  {
      -    "additionalProperties": false,
      -    "properties": {
      -      "headers": {
      -        "anyOf": [
      -          {
      -            "additionalProperties": {
      -              "type": "string"
      -            },
      -            "type": "object"
      -          },
      -          {
      -            "type": "null"
      -          }
      -        ],
      -        "description": "Optional storage headers to include on the PUT call (Content-Type, Cache-Control, x-amz-acl, etc.). Whitelisted at SSRF layer.",
      -        "title": "Headers"
      -      },
      -      "mode": {
      -        "const": "put_url",
      -        "title": "Mode",
      -        "type": "string"
      -      },
      -      "put_url": {
      -        "description": "Customer-signed presigned PUT URL where the optimized bytes will be written. Must be https://. Cloud credentials never reach our infrastructure; only the URL itself is used and discarded after the request.",
      -        "format": "uri",
      -        "maxLength": 2083,
      -        "minLength": 1,
      -        "title": "Put Url",
      -        "type": "string"
      -      }
      -    },
      -    "required": [
      -      "mode",
      -      "put_url"
      -    ],
      -    "title": "PutUrlDelivery",
      -    "type": "object"
      -  },
      -  {
      -    "additionalProperties": false,
      -    "properties": {
      -      "callback_url": {
      -        "description": "Customer endpoint where the optimized bytes will be POSTed. Must be https://. For async/large jobs. We send an X-Pig-Sha256 header of the body so the receiver can verify integrity. No credentials are stored on our side; secure the endpoint with a token in the URL itself.",
      -        "format": "uri",
      -        "maxLength": 2083,
      -        "minLength": 1,
      -        "title": "Callback Url",
      -        "type": "string"
      -      },
      -      "headers": {
      -        "anyOf": [
      -          {
      -            "additionalProperties": {
      -              "type": "string"
      -            },
      -            "type": "object"
      -          },
      -          {
      -            "type": "null"
      -          }
      -        ],
      -        "description": "Optional headers to include on the POST call (Content-Type, Cache-Control, x-amz-*, etc.). Whitelisted at SSRF layer.",
      -        "title": "Headers"
      -      },
      -      "mode": {
      -        "const": "callback_url",
      -        "title": "Mode",
      -        "type": "string"
      -      }
      -    },
      -    "required": [
      -      "mode",
      -      "callback_url"
      -    ],
      -    "title": "CallbackDelivery",
      -    "type": "object"
      -  }
      -]New value: +[
      +  {
      +    "additionalProperties": false,
      +    "properties": {
      +      "mode": {
      +        "const": "inline",
      +        "default": "inline",
      +        "title": "Mode",
      +        "type": "string"
      +      }
      +    },
      +    "title": "InlineDelivery",
      +    "type": "object"
      +  },
      +  {
      +    "additionalProperties": false,
      +    "properties": {
      +      "headers": {
      +        "anyOf": [
      +          {
      +            "additionalProperties": {
      +              "type": "string"
      +            },
      +            "type": "object"
      +          },
      +          {
      +            "type": "null"
      +          }
      +        ],
      +        "description": "Optional storage headers to include on the PUT call (Content-Type, Cache-Control, x-amz-acl, etc.). Whitelisted at SSRF layer.",
      +        "title": "Headers"
      +      },
      +      "mode": {
      +        "const": "put_url",
      +        "title": "Mode",
      +        "type": "string"
      +      },
      +      "put_url": {
      +        "description": "Customer-signed presigned PUT URL where the optimized bytes will be written. Must be https://. Cloud credentials never reach our infrastructure; only the URL itself is used and discarded after the request.",
      +        "format": "uri",
      +        "maxLength": 2083,
      +        "minLength": 1,
      +        "title": "Put Url",
      +        "type": "string"
      +      }
      +    },
      +    "required": [
      +      "mode",
      +      "put_url"
      +    ],
      +    "title": "PutUrlDelivery",
      +    "type": "object"
      +  },
      +  {
      +    "additionalProperties": false,
      +    "properties": {
      +      "callback_url": {
      +        "description": "Customer endpoint where the optimized bytes will be POSTed. Must be https://. For async/large jobs. We send an X-Pig-Sha256 header of the body so the receiver can verify integrity. No credentials are stored on our side; secure the endpoint with a token in the URL itself.",
      +        "format": "uri",
      +        "maxLength": 2083,
      +        "minLength": 1,
      +        "title": "Callback Url",
      +        "type": "string"
      +      },
      +      "headers": {
      +        "anyOf": [
      +          {
      +            "additionalProperties": {
      +              "type": "string"
      +            },
      +            "type": "object"
      +          },
      +          {
      +            "type": "null"
      +          }
      +        ],
      +        "description": "Optional headers to include on the POST call (Content-Type, Cache-Control, x-amz-*, etc.). Whitelisted at SSRF layer.",
      +        "title": "Headers"
      +      },
      +      "mode": {
      +        "const": "callback_url",
      +        "title": "Mode",
      +        "type": "string"
      +      },
      +      "secret": {
      +        "anyOf": [
      +          {
      +            "type": "string"
      +          },
      +          {
      +            "type": "null"
      +          }
      +        ],
      +        "description": "Optional HMAC secret. When set, we sign the POST body with HMAC-SHA256 and send 'X-Pig-Signature: sha256=<hex>'. Used per request and never stored. Recompute the HMAC on your endpoint to authenticate the callback (constant-time compare).",
      +        "title": "Secret"
      +      }
      +    },
      +    "required": [
      +      "mode",
      +      "callback_url"
      +    ],
      +    "title": "CallbackDelivery",
      +    "type": "object"
      +  }
      +]
  5. Changed2 schema fields changed
    • addedInput schema / properties / delivery / discriminator / mapping / callback_url
      Added value: +"#/components/schemas/CallbackDelivery"
    • changedInput schema / properties / delivery / oneOf
      Previous value: -[
      -  {
      -    "additionalProperties": false,
      -    "properties": {
      -      "mode": {
      -        "const": "inline",
      -        "default": "inline",
      -        "title": "Mode",
      -        "type": "string"
      -      }
      -    },
      -    "title": "InlineDelivery",
      -    "type": "object"
      -  },
      -  {
      -    "additionalProperties": false,
      -    "properties": {
      -      "headers": {
      -        "anyOf": [
      -          {
      -            "additionalProperties": {
      -              "type": "string"
      -            },
      -            "type": "object"
      -          },
      -          {
      -            "type": "null"
      -          }
      -        ],
      -        "description": "Optional storage headers to include on the PUT call (Content-Type, Cache-Control, x-amz-acl, etc.). Whitelisted at SSRF layer.",
      -        "title": "Headers"
      -      },
      -      "mode": {
      -        "const": "put_url",
      -        "title": "Mode",
      -        "type": "string"
      -      },
      -      "put_url": {
      -        "description": "Customer-signed presigned PUT URL where the optimized bytes will be written. Must be https://. Cloud credentials never reach our infrastructure; only the URL itself is used and discarded after the request.",
      -        "format": "uri",
      -        "maxLength": 2083,
      -        "minLength": 1,
      -        "title": "Put Url",
      -        "type": "string"
      -      }
      -    },
      -    "required": [
      -      "mode",
      -      "put_url"
      -    ],
      -    "title": "PutUrlDelivery",
      -    "type": "object"
      -  }
      -]New value: +[
      +  {
      +    "additionalProperties": false,
      +    "properties": {
      +      "mode": {
      +        "const": "inline",
      +        "default": "inline",
      +        "title": "Mode",
      +        "type": "string"
      +      }
      +    },
      +    "title": "InlineDelivery",
      +    "type": "object"
      +  },
      +  {
      +    "additionalProperties": false,
      +    "properties": {
      +      "headers": {
      +        "anyOf": [
      +          {
      +            "additionalProperties": {
      +              "type": "string"
      +            },
      +            "type": "object"
      +          },
      +          {
      +            "type": "null"
      +          }
      +        ],
      +        "description": "Optional storage headers to include on the PUT call (Content-Type, Cache-Control, x-amz-acl, etc.). Whitelisted at SSRF layer.",
      +        "title": "Headers"
      +      },
      +      "mode": {
      +        "const": "put_url",
      +        "title": "Mode",
      +        "type": "string"
      +      },
      +      "put_url": {
      +        "description": "Customer-signed presigned PUT URL where the optimized bytes will be written. Must be https://. Cloud credentials never reach our infrastructure; only the URL itself is used and discarded after the request.",
      +        "format": "uri",
      +        "maxLength": 2083,
      +        "minLength": 1,
      +        "title": "Put Url",
      +        "type": "string"
      +      }
      +    },
      +    "required": [
      +      "mode",
      +      "put_url"
      +    ],
      +    "title": "PutUrlDelivery",
      +    "type": "object"
      +  },
      +  {
      +    "additionalProperties": false,
      +    "properties": {
      +      "callback_url": {
      +        "description": "Customer endpoint where the optimized bytes will be POSTed. Must be https://. For async/large jobs. We send an X-Pig-Sha256 header of the body so the receiver can verify integrity. No credentials are stored on our side; secure the endpoint with a token in the URL itself.",
      +        "format": "uri",
      +        "maxLength": 2083,
      +        "minLength": 1,
      +        "title": "Callback Url",
      +        "type": "string"
      +      },
      +      "headers": {
      +        "anyOf": [
      +          {
      +            "additionalProperties": {
      +              "type": "string"
      +            },
      +            "type": "object"
      +          },
      +          {
      +            "type": "null"
      +          }
      +        ],
      +        "description": "Optional headers to include on the POST call (Content-Type, Cache-Control, x-amz-*, etc.). Whitelisted at SSRF layer.",
      +        "title": "Headers"
      +      },
      +      "mode": {
      +        "const": "callback_url",
      +        "title": "Mode",
      +        "type": "string"
      +      }
      +    },
      +    "required": [
      +      "mode",
      +      "callback_url"
      +    ],
      +    "title": "CallbackDelivery",
      +    "type": "object"
      +  }
      +]
  6. Changed1 schema field changed
    • addedInput schema / properties / delivery
      Added value: +{
      +  "discriminator": {
      +    "mapping": {
      +      "inline": "#/components/schemas/InlineDelivery",
      +      "put_url": "#/components/schemas/PutUrlDelivery"
      +    },
      +    "propertyName": "mode"
      +  },
      +  "oneOf": [
      +    {
      +      "additionalProperties": false,
      +      "properties": {
      +        "mode": {
      +          "const": "inline",
      +          "default": "inline",
      +          "title": "Mode",
      +          "type": "string"
      +        }
      +      },
      +      "title": "InlineDelivery",
      +      "type": "object"
      +    },
      +    {
      +      "additionalProperties": false,
      +      "properties": {
      +        "headers": {
      +          "anyOf": [
      +            {
      +              "additionalProperties": {
      +                "type": "string"
      +              },
      +              "type": "object"
      +            },
      +            {
      +              "type": "null"
      +            }
      +          ],
      +          "description": "Optional storage headers to include on the PUT call (Content-Type, Cache-Control, x-amz-acl, etc.). Whitelisted at SSRF layer.",
      +          "title": "Headers"
      +        },
      +        "mode": {
      +          "const": "put_url",
      +          "title": "Mode",
      +          "type": "string"
      +        },
      +        "put_url": {
      +          "description": "Customer-signed presigned PUT URL where the optimized bytes will be written. Must be https://. Cloud credentials never reach our infrastructure; only the URL itself is used and discarded after the request.",
      +          "format": "uri",
      +          "maxLength": 2083,
      +          "minLength": 1,
      +          "title": "Put Url",
      +          "type": "string"
      +        }
      +      },
      +      "required": [
      +        "mode",
      +        "put_url"
      +      ],
      +      "title": "PutUrlDelivery",
      +      "type": "object"
      +    }
      +  ],
      +  "title": "delivery",
      +  "type": "string"
      +}
  7. Added

TDQS

A3.9/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries full burden. It discloses mutual exclusivity of modes, smart crop clamping, trim header reporting, and enhancement order. However, it omits major behavioral aspects like the delivery parameter (inline vs put_url vs callback) and autorot EXIF handling, which are important for agent usage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with a summary followed by mode details and enhancements. However, the response examples are redundant and uninformative (repeated 'string' JSON), adding unnecessary length. Could be more concise.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (14 parameters, no output schema), the description covers modes and enhancements but fails to explain the delivery parameter, autorot behavior, or error responses. The response section is minimal and does not clarify the return format beyond 'binary' and Content-Type examples.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 93%, so baseline is 3. The description adds value by grouping parameters into modes, clarifying mutual exclusivity, and specifying enhancement application order. It also explains gravity options and trim threshold context beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'Crop an image' and explains the three mutually exclusive modes (manual, smart crop, trim). It uses a specific verb-resource pair and distinguishes the tool from siblings like resize or compress by focusing on region extraction.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use each mode (e.g., manual for explicit coordinates, smart crop for automatic window picking, trim for removing borders). However, it does not explicitly compare to sibling tools or state when not to use crop_image, leaving the selection largely implicit.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources