Passport Photo Crop API and Document Portrait Crop

Create pose-aware portrait crops for passport photos, ID photos, profile photos, and document-photo workflows.

This guide is for teams looking for a passport photo crop API, ID photo crop API, document portrait crop API, or automatic profile photo crop. The Crop plugin can use person landmarks to find the face and upper body, straighten the portrait by the person/eye-line orientation, and return a ready document-style portrait JPEG from the API.

This API prepares the document-style crop. It does not certify compliance with a specific country's official passport-photo rules. Check background, head size, eye line, print size, and local document requirements in your own application.

Source portrait for document crop
Source portrait preview. Download source preview JPEG
Ready document portrait crop result from the API
Ready document portrait crop returned by the API. Download crop JPEG

Recommended Payload

Use AutoMode: "Fixed" with CropModeIndex: 0 for the document/passport-style portrait preset. Set AutoStraightenMode: "Person" so the crop is straightened from person landmarks instead of the general full-image AI straighten mode. Set AspectRatio: "3 : 4", use a moderate Extend value so the document crop is not too tight, and enable fixed output sizing so the API returns a ready document-photo JPEG.

{
  "mode": "professional",
  "outputFormat": "jpeg",
  "tasks": [
    {
      "Plugin": "Crop",
      "Layer": 0,
      "User Params": {
        "AutoMode": "Fixed",
        "AutoStraightenMode": "Person",
        "CropModeIndex": 0,
        "AspectRatio": "3 : 4",
        "CustomAspectX": 3,
        "CustomAspectY": 4,
        "CenterFaceHorizontally": true,
        "CustomMargins": false,
        "Extend": 25,
        "FixSize": true,
        "FixSizePixels": 512,
        "OnlyMainSubject": false
      }
    }
  ]
}

Fields That Matter for Document Photos

FieldRecommended valueWhy
AutoModeFixedUses a deterministic person crop preset.
AutoStraightenModePersonUses person landmarks and eye-line orientation. Do not use AI here if the goal is a document portrait crop.
CropModeIndex0Uses the passport/document-style crop preset.
AspectRatio3 : 4Common portrait ratio for ID and document-photo workflows.
Extend25Adds document-photo breathing room around the head and shoulders so the crop is not an avatar-style close-up.
FixSizetrueMakes the output predictable for automated systems.
FixSizePixels512Returns a ready 3:4 document crop directly from the API. With this ratio and fixed size, the output is 384x512 px.

Integration Flow

  1. Upload the portrait with the payload above to /retoucher/start.
  2. Poll /retoucher/status/{id} until the job is completed.
  3. Download the ready document-photo JPEG from /retoucher/getFile/{id}.
  4. Run your own country-specific document-photo validation if required by your product.

Before and After Series

The same payload was applied to three ID-style source portraits. PortraitForID_HDR_2350 is used as the main example because it gives the cleanest document-style framing.

Source preview Ready API crop
PortraitForID HDR 2314 source portrait preview PortraitForID HDR 2314 ready document crop from the API
PortraitForID HDR 2335 source portrait preview PortraitForID HDR 2335 ready document crop from the API
PortraitForID HDR 2350 source portrait preview PortraitForID HDR 2350 ready document crop from the API

Heal, Dodge Burn, and Crop in One Request

For a ready retouched document portrait, put retouching plugins before Crop and keep Crop as the final task. The API then returns one flattened JPEG that is healed, enhanced with Dodge Burn, and cropped. Use conservative retouch strength for ID and passport-photo workflows, because many document systems expect a natural-looking face.

For the broader retouching workflow and plugin parameters, see All-In-One Retouching and the professional-mode task reference.

Document portrait crop before Heal retouching
Before: document crop only. Download Crop-only JPEG
Document portrait after Heal, Dodge Burn, and Crop in one API request
After: Heal at 70%, Dodge Burn at 30%, then Crop in one API request. Download Heal + Dodge Burn + Crop JPEG
{
  "mode": "professional",
  "outputFormat": "jpeg",
  "tasks": [
    {
      "Plugin": "Heal",
      "Scale": 0,
      "Alpha1": 0.7,
      "Layer": 0
    },
    {
      "Plugin": "Dodge Burn",
      "Scale": 2,
      "Alpha1": 0.3,
      "Alpha2": 0.0,
      "Layer": 0
    },
    {
      "Plugin": "Crop",
      "Layer": 0,
      "User Params": {
        "AutoMode": "Fixed",
        "AutoStraightenMode": "Person",
        "CropModeIndex": 0,
        "AspectRatio": "3 : 4",
        "CustomAspectX": 3,
        "CustomAspectY": 4,
        "CenterFaceHorizontally": true,
        "CustomMargins": false,
        "Extend": 25,
        "FixSize": true,
        "FixSizePixels": 512,
        "OnlyMainSubject": false
      }
    }
  ]
}

Related Crop Guides

For other portrait crop presets and pose metadata, see Pose Crop. For product-object crop and mask metadata, see Subject Crop and RLE Mask. For manually tuned crop frames, use the Crop manual playground.