Skip to content

Image Composition

Layer an overlay image on top of a base image with configurable position, opacity, and blend mode. Useful for compositing logos, graphics, or combining multiple images.

API Endpoint

POST /api/v1/tools/compose

Accepts multipart form data with two image files and a JSON settings field.

Parameters

ParameterTypeRequiredDefaultDescription
xnumberNo0Horizontal offset of the overlay from the top-left corner in pixels (min 0)
ynumberNo0Vertical offset of the overlay from the top-left corner in pixels (min 0)
opacitynumberNo100Overlay opacity percentage (0 to 100)
blendModestringNo"over"Compositing blend mode

Blend Modes

ValueDescription
overNormal overlay (default)
multiplyDarken by multiplying pixel values
screenLighten by inverting, multiplying, and inverting again
overlayCombines multiply and screen based on base brightness
darkenKeep the darker pixel from each layer
lightenKeep the lighter pixel from each layer
hard-lightStrong contrast overlay
soft-lightSubtle contrast overlay
differenceAbsolute difference between layers
exclusionSimilar to difference but lower contrast

File Fields

Field NameRequiredDescription
fileYesThe base/background image
overlayYesThe overlay/foreground image

Example Request

bash
curl -X POST http://localhost:1349/api/v1/tools/compose \
  -H "Authorization: Bearer si_your-api-key" \
  -F "[email protected]" \
  -F "[email protected]" \
  -F 'settings={"x": 100, "y": 50, "opacity": 80, "blendMode": "over"}'

Using multiply blend mode:

bash
curl -X POST http://localhost:1349/api/v1/tools/compose \
  -H "Authorization: Bearer si_your-api-key" \
  -F "[email protected]" \
  -F "[email protected]" \
  -F 'settings={"x": 0, "y": 0, "opacity": 50, "blendMode": "multiply"}'

Example Response

json
{
  "jobId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/background.jpg",
  "originalSize": 3200000,
  "processedSize": 3450000
}

Notes

  • Both images are validated and decoded (HEIC, RAW, PSD, SVG supported) before compositing.
  • The overlay is placed at the exact pixel coordinates specified by x and y. It is not resized to fit.
  • If opacity is less than 100, an alpha mask is applied to the overlay before blending.
  • The overlay can extend beyond the base image boundaries (it will be clipped).
  • EXIF orientation is auto-applied on both images before processing.
  • Output dimensions match the base image dimensions.