Document Operations Migration

This guide helps you migrate from the v1 /pie/psdService/documentOperations endpoint to the v2 /create-composite endpoint for document-level editing operations.

Overview

In v1, the /documentOperations endpoint was used for document-level operations like cropping, resizing, and trimming existing PSD files. These operations affect the entire document rather than individual layers.

V1 Endpoint:

POST /pie/psdService/documentOperations

V2 Endpoint:

POST /v2/create-composite

In v2, document operations are specified in the edits.document object within the /create-composite request.

data-variant=warning
data-slots=header,text
Important:
V2 currently supports a subset of V1 document operation features. Additional capabilities are being added incrementally. Review the available operations below to ensure your use case is supported.

Key differences

Available document operations

V2 currently supports the following document operations:

When to use document operations

Use Document Operations when:

Use Format Conversion when:

Use Document Creation when:

Use Composite Operations when:

Resize operations

Resize changes the dimensions of the entire document, affecting all layers.

Key Points:

V2 Example:

curl -X POST \
  https://photoshop-api.adobe.io/v2/create-composite \
  -H "Authorization: Bearer $token" \
  -H "x-api-key: $apiKey" \
  -H "Content-Type: application/json" \
  -d '{
  "image": {
    "source": {
      "url": "<SIGNED_GET_URL>"
    }
  },
  "edits": {
    "document": {
      "resize": {
        "width": {
          "unit": "pixels_unit",
          "value": 1920
        },
        "height": {
          "unit": "pixels_unit",
          "value": 1080
        },
        "constrainProportions": true,
        "resample": "bicubic",
        "scaleStyles": true
      }
    }
  },
  "outputs": [
    {
      "destination": {
        "url": "<SIGNED_POST_URL>"
      },
      "mediaType": "image/vnd.adobe.photoshop"
    }
  ]
}'

Resize parameters

width and height

Both width and height are objects with unit and value properties:

{
  "width": {
    "unit": "pixels_unit",
    "value": 1920
  },
  "height": {
    "unit": "pixels_unit",
    "value": 1080
  }
}

Unit Types:

constrainProportions

resample

scaleStyles

rasterize

Resize examples

Resize with Constrained Proportions:

{
  "edits": {
    "document": {
      "resize": {
        "width": {
          "unit": "pixels_unit",
          "value": 1920
        },
        "constrainProportions": true,
        "resample": "bicubic"
      }
    }
  }
}

When constrainProportions is true, you only need to specify width OR height. The other dimension will be calculated automatically.

Resize by Percentage:

{
  "edits": {
    "document": {
      "resize": {
        "width": {
          "unit": "percent_unit",
          "value": 50
        },
        "height": {
          "unit": "percent_unit",
          "value": 50
        },
        "resample": "bicubic_sharper"
      }
    }
  }
}

Resize to Exact Dimensions:

{
  "edits": {
    "document": {
      "resize": {
        "width": {
          "unit": "pixels_unit",
          "value": 800
        },
        "height": {
          "unit": "pixels_unit",
          "value": 600
        },
        "constrainProportions": false,
        "resample": "bicubic"
      }
    }
  }
}

Upscaling with Smooth Interpolation:

{
  "edits": {
    "document": {
      "resize": {
        "width": {
          "unit": "pixels_unit",
          "value": 4000
        },
        "constrainProportions": true,
        "resample": "bicubic_smoother",
        "scaleStyles": true
      }
    }
  }
}

Downscaling with Sharp Interpolation:

{
  "edits": {
    "document": {
      "resize": {
        "width": {
          "unit": "pixels_unit",
          "value": 800
        },
        "constrainProportions": true,
        "resample": "bicubic_sharper",
        "scaleStyles": true
      }
    }
  }
}

Crop operations

Crop removes portions of the document based on specified boundaries.

Key Points:

V2 Approach:

curl -X POST \
  https://photoshop-api.adobe.io/v2/create-composite \
  -H "Authorization: Bearer $token" \
  -H "x-api-key: $apiKey" \
  -H "Content-Type: application/json" \
  -d '{
  "image": {
    "source": {
      "url": "<SIGNED_GET_URL>"
    }
  },
  "edits": {
    "document": {
      "crop": {
        "bounds": {
          "left": 100,
          "top": 100,
          "right": 1820,
          "bottom": 980
        },
        "hide": false
      }
    }
  },
  "outputs": [
    {
      "destination": {
        "url": "<SIGNED_POST_URL>"
      },
      "mediaType": "image/vnd.adobe.photoshop"
    }
  ]
}'

Crop parameters

bounds

Defines the crop rectangle in pixels:

{
  "bounds": {
    "left": 100, // Left edge X coordinate
    "top": 100, // Top edge Y coordinate
    "right": 1820, // Right edge X coordinate
    "bottom": 980 // Bottom edge Y coordinate
  }
}

hide

Crop examples

Destructive Crop (Delete Pixels):

{
  "edits": {
    "document": {
      "crop": {
        "bounds": {
          "left": 0,
          "top": 0,
          "right": 1920,
          "bottom": 1080
        },
        "hide": false
      }
    }
  }
}

Non-Destructive Crop (Hide Pixels):

{
  "edits": {
    "document": {
      "crop": {
        "bounds": {
          "left": 100,
          "top": 100,
          "right": 1820,
          "bottom": 980
        },
        "hide": true
      }
    }
  }
}

Center Crop:

For a 1920x1080 image, crop to 1200x800 centered:

{
  "edits": {
    "document": {
      "crop": {
        "bounds": {
          "left": 360, // (1920 - 1200) / 2
          "top": 140, // (1080 - 800) / 2
          "right": 1560, // 360 + 1200
          "bottom": 940 // 140 + 800
        },
        "hide": false
      }
    }
  }
}

Square Crop:

{
  "edits": {
    "document": {
      "crop": {
        "bounds": {
          "left": 420, // Center 1080x1080 in 1920 width
          "top": 0,
          "right": 1500, // 420 + 1080
          "bottom": 1080
        },
        "hide": false
      }
    }
  }
}

Trim operations

Trim automatically removes transparent pixels from the edges of the document.

Key Points:

V2 Approach:

curl -X POST \
  https://photoshop-api.adobe.io/v2/create-composite \
  -H "Authorization: Bearer $token" \
  -H "x-api-key: $apiKey" \
  -H "Content-Type: application/json" \
  -d '{
  "image": {
    "source": {
      "url": "<SIGNED_GET_URL>"
    }
  },
  "edits": {
    "document": {
      "trim": {
        "trimUpon": "transparent_pixels"
      }
    }
  },
  "outputs": [
    {
      "destination": {
        "url": "<SIGNED_POST_URL>"
      },
      "mediaType": "image/vnd.adobe.photoshop"
    }
  ]
}'

Trim parameters

trimUpon

data-variant=info
data-slots=text
Additional trim options (like trim based on pixel color) are planned for future releases.

Combining multiple document operations

You can combine multiple document operations in a single request. Operations are applied in order: resize, then crop, then trim.

Key Points:

V2 Approach:

curl -X POST \
  https://photoshop-api.adobe.io/v2/create-composite \
  -H "Authorization: Bearer $token" \
  -H "x-api-key: $apiKey" \
  -H "Content-Type: application/json" \
  -d '{
  "image": {
    "source": {
      "url": "<SIGNED_GET_URL>"
    }
  },
  "edits": {
    "document": {
      "resize": {
        "width": {
          "unit": "pixels_unit",
          "value": 2000
        },
        "constrainProportions": true,
        "resample": "bicubic"
      },
      "crop": {
        "bounds": {
          "left": 100,
          "top": 100,
          "right": 1900,
          "bottom": 1000
        },
        "hide": false
      },
      "trim": {
        "trimUpon": "transparent_pixels"
      }
    }
  },
  "outputs": [
    {
      "destination": {
        "url": "<SIGNED_POST_URL>"
      },
      "mediaType": "image/vnd.adobe.photoshop"
    }
  ]
}'

Combining with output conversion

Apply document operations and convert to different formats in one request:

Key Points:

curl -X POST \
  https://photoshop-api.adobe.io/v2/create-composite \
  -H "Authorization: Bearer $token" \
  -H "x-api-key: $apiKey" \
  -H "Content-Type: application/json" \
  -d '{
  "image": {
    "source": {
      "url": "<SIGNED_GET_URL>"
    }
  },
  "edits": {
    "document": {
      "resize": {
        "width": {
          "unit": "pixels_unit",
          "value": 1920
        },
        "constrainProportions": true,
        "resample": "bicubic"
      }
    }
  },
  "outputs": [
    {
      "destination": {
        "url": "<PSD_URL>"
      },
      "mediaType": "image/vnd.adobe.photoshop"
    },
    {
      "destination": {
        "url": "<JPEG_URL>"
      },
      "mediaType": "image/jpeg",
      "quality": "high"
    }
  ]
}'

Common use cases

Thumbnail generation

Resize and crop to create thumbnails:

{
  "edits": {
    "document": {
      "resize": {
        "width": {
          "unit": "pixels_unit",
          "value": 400
        },
        "constrainProportions": true,
        "resample": "bicubic_sharper"
      }
    }
  }
}

Image optimization

Resize for web delivery:

{
  "edits": {
    "document": {
      "resize": {
        "width": {
          "unit": "pixels_unit",
          "value": 1920
        },
        "constrainProportions": true,
        "resample": "bicubic"
      }
    }
  }
}

Aspect ratio correction

Crop to specific aspect ratio (e.g., 16:9):

{
  "edits": {
    "document": {
      "crop": {
        "bounds": {
          "left": 0,
          "top": 120,
          "right": 1920,
          "bottom": 1200
        },
        "hide": false
      }
    }
  }
}

Clean up transparent edges

Trim unnecessary transparent space:

{
  "edits": {
    "document": {
      "trim": {
        "trimUpon": "transparent_pixels"
      }
    }
  }
}

Common migration issues

Invalid unit type

Problem: Using incorrect unit type

{
  "width": {
    "unit": "px",
    "value": 1920
  }
}

Solution: Use valid unit types

{
  "width": {
    "unit": "pixels_unit",
    "value": 1920
  }
}

Missing unit object

Problem: Specifying width/height as numbers

{
  "resize": {
    "width": 1920,
    "height": 1080
  }
}

Solution: Use proper unit object structure

{
  "resize": {
    "width": {
      "unit": "pixels_unit",
      "value": 1920
    },
    "height": {
      "unit": "pixels_unit",
      "value": 1080
    }
  }
}

Invalid crop bounds

Problem: Crop bounds outside document dimensions

{
  "bounds": {
    "left": 0,
    "top": 0,
    "right": 5000, // Exceeds document width
    "bottom": 3000 // Exceeds document height
  }
}

Solution: Ensure bounds are within document dimensions

{
  "bounds": {
    "left": 0,
    "top": 0,
    "right": 1920, // Within document width
    "bottom": 1080 // Within document height
  }
}

Feature availability

Currently available

Coming soon

Next steps

Need help?

Contact the Adobe DI ART Service team for technical support with document operations.