Skip to main content
Version: 1.11.0-beta

maskImage

Submits two image URLs (original and mask) to the edit server for masking/inpainting.

Signature:

client.edit.maskImage(
originalImageUrl: string,
maskImageUrl: string,
editServerUrl?: string
): Promise<Blob | NodeJS.ReadableStream>
  • originalImageUrl: URL of the original image.

  • maskImageUrl: URL of the mask image.

  • editServerUrl (optional): Overrides the default edit server URL.

  • Returns:

    • Browser: Blob (PNG image)
    • Node.js: NodeJS.ReadableStream
  • Throws: On validation, network, or API error.

Example (Browser)

const client = new ImagineoAIClient(apiUrl, { apiKey: 'sk-...' });
const pngBlob = await client.edit.maskImage(
"https://example.com/original.png",
"https://example.com/mask.png"
);
// Use the Blob as needed (e.g., display, download)

Example (Node.js)

const client = new ImagineoAIClient(apiUrl, { apiKey: 'sk-...' });
const fs = require('fs');
const pngStream = await client.edit.maskImage(
"https://example.com/original.png",
"https://example.com/mask.png"
);
pngStream.pipe(fs.createWriteStream("./output.png"));

Notes

  • Sends JSON payload { image_url, mask_url } to the edit endpoint.
  • Default endpoint: /api/v1/edits/mask.
  • See API Reference for more details on inputs/outputs.