Skip to main content
Alpha: Document API is currently alpha and subject to breaking changes.

Summary

Apply rectangular edge-percentage crop to an image.
  • Operation ID: images.crop
  • API member path: editor.doc.images.crop(...)
  • Mutates document: yes
  • Idempotency: conditional
  • Supports tracked mode: no
  • Supports dry run: yes
  • Deterministic target resolution: yes

Expected result

Returns an ImagesMutationResult; reports NO_OP if unchanged.

Input fields

FieldTypeRequiredDescription
cropobjectyes
crop.bottomnumberno
crop.leftnumberno
crop.rightnumberno
crop.topnumberno
imageIdstringyes

Example request

{
  "crop": {
    "left": 12.5,
    "top": 12.5
  },
  "imageId": "example"
}

Output fields

FieldTypeRequiredDescription
failureobjectno
imageobjectno
successbooleanno

Example response

{
  "image": {},
  "success": true
}

Pre-apply throws

  • TARGET_NOT_FOUND
  • AMBIGUOUS_TARGET
  • INVALID_TARGET
  • CAPABILITY_UNAVAILABLE
  • INVALID_INPUT

Non-applied failure codes

  • NO_OP

Raw schemas

{
  "additionalProperties": false,
  "properties": {
    "crop": {
      "additionalProperties": false,
      "properties": {
        "bottom": {
          "maximum": 100,
          "minimum": 0,
          "type": "number"
        },
        "left": {
          "maximum": 100,
          "minimum": 0,
          "type": "number"
        },
        "right": {
          "maximum": 100,
          "minimum": 0,
          "type": "number"
        },
        "top": {
          "maximum": 100,
          "minimum": 0,
          "type": "number"
        }
      },
      "type": "object"
    },
    "imageId": {
      "type": "string"
    }
  },
  "required": [
    "imageId",
    "crop"
  ],
  "type": "object"
}
{
  "additionalProperties": false,
  "properties": {
    "failure": {
      "type": "object"
    },
    "image": {
      "type": "object"
    },
    "success": {
      "type": "boolean"
    }
  },
  "type": "object"
}
{
  "additionalProperties": false,
  "properties": {
    "image": {
      "type": "object"
    },
    "success": {
      "const": true
    }
  },
  "required": [
    "success",
    "image"
  ],
  "type": "object"
}
{
  "additionalProperties": false,
  "properties": {
    "failure": {
      "additionalProperties": false,
      "properties": {
        "code": {
          "type": "string"
        },
        "message": {
          "type": "string"
        }
      },
      "required": [
        "code",
        "message"
      ],
      "type": "object"
    },
    "success": {
      "const": false
    }
  },
  "required": [
    "success",
    "failure"
  ],
  "type": "object"
}