Free plan

Generate Variants

Make several named versions of one picture at once
POST
/v1/images/variants

About this tool

This tool makes several different versions of one picture in one go. You define each version with a name and its own size or settings, for example small, medium and large. You can also apply a common edit to the source first. It takes one picture and up to 10 versions. This is useful when a website needs a different size for each screen.
For example, you create a thumbnail, a mobile version and a desktop version of the same photo.

How to use it

  1. Choose this tool.
  2. Add one picture with Upload or drag and drop.
  3. Add each version you need and give it a name and a size.
  4. Add a common edit for all versions if you want one.
  5. Press Generate, then download the versions.

What you get back

You get one new picture for each version, named as you chose. Download them one by one or as a ZIP if offered.
GOOD TO KNOW
More than one uploaded file -> 400. Each variant is derived independently from the (optionally preprocessed) source, so order never matters.
TEST IT LIVE

Try Generate Variants in the Studio

One click opens the Studio with this tool already selected. Add your file and see the result in seconds.
Open in the Studio
Family
Images
Plan
Free
Method
POST
Endpoint
/v1/images/variants
Tool ID
images.variants
Authentication
API key
Accepts
JPEG, PNG, WEBP, GIF, AVIF, TIFF +15 more
Background jobs
Yes
Usage group
Image
For developers

Use it from your code

cURL

curl -X POST "https://app.h2i.davixlabs.io/v1/images/variants" \
  -H "X-Api-Key: $DAVIX_H2I_API_KEY" \
  -F 'images=@photo.jpg' \
  -F 'variants=[{"name":"x"}]' \
  -F 'output_bundle=zip' \
  -F 'response=url'

Node.js

const { DavixH2I } = require('@davixlabs/h2i-sdk');

const h2i = new DavixH2I({ apiKey: process.env.DAVIX_H2I_API_KEY, baseUrl: process.env.DAVIX_H2I_URL });
const result = await h2i.images.variants({
    "images": 'photo.jpg',
    "variants": [
      {
        "name": "x"
      }
    ],
    "output_bundle": "zip",
    "response": "url"
  });
console.log(result.data, result.requestId);

PHP

<?php
require 'vendor/autoload.php';

$h2i = new \Davix\H2I\Client(['apiKey' => getenv('DAVIX_H2I_API_KEY'), 'baseUrl' => getenv('DAVIX_H2I_URL')]);
$result = $h2i->images()->variants([
    'images' => 'photo.jpg',
    'variants' => [[
            'name' => 'x',
        ]],
    'output_bundle' => 'zip',
    'response' => 'url',
]);
echo $result->requestId;
FAQ

Frequently asked questions

Make several named versions of one picture at once.

Generate Variants accepts JPEG, PNG, WEBP, GIF, AVIF, TIFF, SVG, SVGZ, BMP, ICO, APNG, PNM and 9 more. You can send several files in one request.

Generate Variants is included in every plan, including Free. Each run uses credits from your monthly allowance.

Send a POST request to /v1/images/variants with your API key in the X-Api-Key header. Official SDKs for Node.js, Python, PHP, Go, Java, .NET and Ruby do the same for you, and the code box on this page shows ready-to-copy examples. For large work it can also run as a background job, so your request returns straight away.