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-v2"; const data = { "base_image": toB64('https://segmind-sd-models.s3.amazonaws.com/display_images/superimpose-v2-model.jpeg'), "overlay_image": "toB64('https://segmind-sd-models.s3.amazonaws.com/display_images/tshirt-logo-2.png')", "mask": "toB64('null')", "rescale_factor": 0.4, "resize_method": "nearest", "bg_remove_model": "Bria", "mirror": "None", "blend_mode": "screen", "opacity": 90, "x_percent": 50, "y_percent": 65, "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 : 100


resize_methodenum:str ( default: nearest )

Resize Method for Overlay Image.

Allowed values:


bg_remove_modelenum:str ( default: Bria )

BG Removal Model

Allowed values:


mirrorenum:str ( default: None )

Mirror

Allowed values:


blend_modeenum:str ( default: multiply )

Blend Mode

Allowed values:


opacityfloat ( default: 90 )

Opacity of the Overlay Image

min : 0,

max : 100


x_percentint ( default: 50 ) Affects Pricing

X Percent

min : 0,

max : 100


y_percentint ( default: 80 ) Affects Pricing

Y Percent

min : 0,

max : 100


rotationenum:int ( default: 1 ) Affects Pricing

Rotation

Allowed values:

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 V2

Superimpose V2 allows you to easily create captivating visuals by seamlessly overlaying one image on top of another. You have various ways to resize the overlay image, including maintaining its proportions, setting specific dimensions, or automatically fitting it to the base image. Additionally, you can choose from different resizing methods to achieve smooth transitions, exceptional quality, or faster processing depending on your needs. Finally, precise positioning tools let you perfectly align the overlay image on the base image. This is an improvement over Superimpose v1 to make image editing more seamless than before.

What’s new in Superimpose V2

  1. Background removal is baked into the model, to create transparent background images. No need to upload pre-existing transparent images like Superimpose v1.

  2. The blending mode specified in the options bar controls how pixels in the image are affected by superimposition. There are 14 blending modes present. Think in terms of the following colors when visualizing a blending mode’s effect:

  • The base color is the original color in the image.

  • The blend color is the color being applied with the superimposition.

  • The result color is the color resulting from the blend.