POST
javascript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 const axios = require('axios'); const fs = require('fs'); const path = require('path'); async function toB64(imgPath) { const data = fs.readFileSync(path.resolve(imgPath)); return Buffer.from(data).toString('base64'); } const api_key = "YOUR API-KEY"; const url = "https://api.segmind.com/v1/superimpose"; const data = { "base_image": toB64('https://segmind-sd-models.s3.amazonaws.com/display_images/tshirt+mock.jpg'), "overlay_image": "toB64('https://segmind-sd-models.s3.amazonaws.com/display_images/tshirt+logo.png')", "mask": "toB64('undefined')", "rescale_factor": 0.4, "resize_method": "nearest-exact", "overlay_resize": "Resize by rescale_factor", "opacity": 1, "height": 1024, "width": 1024, "x_offset": 320, "y_offset": 620, "rotation": 0, "base64": false }; (async function() { try { const response = await axios.post(url, data, { headers: { 'x-api-key': api_key } }); console.log(response.data); } catch (error) { console.error('Error:', error.response.data); } })();
RESPONSE
image/jpeg
HTTP Response Codes
200 - OKImage Generated
401 - UnauthorizedUser authentication failed
404 - Not FoundThe requested URL does not exist
405 - Method Not AllowedThe requested HTTP method is not allowed
406 - Not AcceptableNot enough credits
500 - Server ErrorServer had some issue with processing

Attributes


base_imageimage *

Base image for the model


overlay_imageimage *

Overlay image for the model


maskimage ( default: 1 )

Mask for the overlay image


rescale_factorfloat ( default: 1 )

Rescale factor for the overlay image

min : 0,

max : 16


resize_methodenum:str ( default: nearest-exact )

Resize Method for Overlay Image.

Allowed values:


overlay_resizeenum:str ( default: Resize by rescale_factor )

Overlay Image Resize

Allowed values:


opacityfloat ( default: 1 )

Opacity of the Overlay Image

min : 0,

max : 1


heightint ( default: 1024 ) Affects Pricing

Height


widthint ( default: 1024 ) Affects Pricing

Width


x_offsetint ( default: 1 ) Affects Pricing

X Offset


y_offsetint ( default: 1 ) Affects Pricing

Y Offset


rotationint ( default: 1 ) Affects Pricing

Rotation

min : 0,

max : 360


base64boolean ( default: 1 )

Base64 encoding of the output image.

To keep track of your credit usage, you can inspect the response headers of each API call. The x-remaining-credits property will indicate the number of remaining credits in your account. Ensure you monitor this value to avoid any disruptions in your API usage.

Superimpose

Superimpose model lets you to create captivating visuals by seamlessly overlaying one image on top of another. It offers a user-friendly interface with granular control over placement and resizing, making it ideal for a variety of creative tasks.

Key Features of Superimpose

  • Intuitive Image Overlaying: Effortlessly combine two images to create unique compositions, perfect for photo collages, product mockups, and creative marketing materials.

  • Flexible Resizing Options:

    • Scale Factor: Resize the overlay image based on a specific multiplier, maintaining aspect ratio.

    • Height & Width: Set precise dimensions for the overlay image, independent of the scale factor.

    • None: Preserve the original size of the overlay image.

    • Fit: Automatically resize the overlay image to perfectly match the dimensions of the base image.

  • Advanced Resize Methods: Choose from various resizing algorithms to achieve your desired visual effect:

    • Bilinear: Creates smoother transitions by blending nearby pixels. Best for general image resizing.

    • Area: Provides exceptional image quality, particularly during downscaling, by prioritizing pixel area relationships.

    • Nearest: Offers faster processing but may result in a blocky appearance. Suitable for specific use cases where preserving sharp edges is crucial.

  • Precise Positioning: Utilize X-Offset and Y-Offset controls to meticulously position the overlay image on the base image, ensuring flawless alignment.