Images

Generate image with POST request

Create image synchronously

POST https://api.usestencil.com/v1/images/sync

Create image synchronously and get the result in within the same request.

Request Body

Name
Type
Description

modifications

array

Array of modification objects

metadata

object

Extra metadata to be included together with the webhook

webhook_url

string

URL of the webhook to be called when the image is done processing

template

string

The ID of the template

transparent

boolean

Set image background transparency

png_multiplier

integer

jpeg_quality

float

{    "name": "Cake's name",    "recipe": "Cake's recipe name",    "cake": "Binary cake"}

Create image asynchronously

POST https://api.usestencil.com/v1/images

Create image asynchronously. Once image is done processing, the specified webhook is called with the generated image.

Request Body

Name
Type
Description

modifications

array

Array of modifications objects

metadta

object

Extra metadata to be included together with the webhook

webhook_url

string

URL of the webhook to be called when the image is done processing

template

string

The ID of the template

transparent

boolean

Set image background transparency

png_multiplier

integer

jpeg_quality

float

Modification object

Modification object generally follows the following pattern,

  "modifications": [
    {
      "name": "text_1",
      "text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do..."
    },
    {
      "name": "rating_3",
      "rating": 3.5
    }
  ]

name is a required property.

The name is the field unique identifier in the template editor

The rest of the properties depend on the type of object. If you need full list of supported properties, you can view them in them in API Console.

Image Quality

PNG

For PNG images, you can set png_multiplier to adjust the quality of generated images.

For example, if your template size is 800x800 then setting the png_multiplier to 2 will scale the image to 1600x1600 which creates a higher resolution image.

Please note that higher quality image will increase the image size and will also increase the image generation time.

JPEG

For JPEG images, you can set jpeg_quality to adjust the quality of generated images. JPEG is a lossy format, while it offers higher compression rate that could decrease the file size, it also degrades the image quality.

You can control this by setting jpeg_quality to a number between 0 and 1 with 1 being the highest quality.

Please note that higher quality image will increase the image size and will also increase the image generation time.

Default Settings

You can also set a default settings for all templates in your project. Go to your project's settings page and set the values accordingly.

You can always override these values in the API by following the instructions mentioned above.

Last updated