Documentation

Welcome to the PresetBot docs.


Apply Presets via the API

curl -X POST "https://api.presetbot.com/preset/apply?output=jpeg&quality=80" \
     -H "x-api-key: YOUR_API_KEY" \
     -F 'image=@input.jpg' \
     -F 'preset=@preset.xmp' \
     -o output.jpg

To apply an XMP preset to an image, you call the https://api.presetbot.com/preset/apply endpoint with an API key header, files, and optional URL parameters.

API Key Header

You must authenticate using the x-api-key header. You can retrieve your API key on your account dashboard. Make sure this is kept secure and not embedded into any user clients!

Input Files

We accept the input files using multipart/form-data, which requires a file identifier and the file itself. Two files are required:

  • image
    • The input image in either JPEG or AVIF file format. Must be less than 60MP.
  • preset
    • The XMP Lightroom preset.
    • We only apply color-based settings (contrast, brightness, gamma, etc).
    • We do not support dynamic effects such as grain, vignetting, and sharpening.
    • We do not support lrtemplate files.
    • We do not support XMP files from other image editors.

Optional URL Parameters

  • output
    • type: string
    • allowed: jpeg, avif
    • default: jpeg
  • quality
    • type: integer
    • allowed: 1 to 100, inclusive
    • default: 80

If you use cURL, you can use -o output.jpg write the result to a file called output.jpg.


Languages

Python

To access PresetBot with Python, you can use the requests library:

import requests
 
api_endpoint = "https://api.presetbot.com/preset/apply?output=jpeg&quality=80"
 
headers = {
    "x-api-key": "YOUR_API_KEY"
}
 
files = {
    'image': ('input.jpg', open('input.jpg', 'rb')),
    'preset': ('preset.xmp', open('preset.xmp', 'rb'))
}
 
# Make the POST request
response = requests.post(api_endpoint, headers=headers, files=files)
 
# Save the output to a file
if response.status_code == 200:
  with open('output.jpg', 'wb') as file:
      file.write(response.content)
else:
    print(f"Error: {response.status_code}")

Ensure you have the requests library installed in your Python environment or install it:

pip install requests

Replace "YOUR_API_KEY" with your actual API key from your dashboard. Also, ensure that the files 'input.jpg' and 'preset.xmp' exist in the same directory as your script, or provide the correct path to them. This script sends a POST request to the API endpoint, attaches the image and preset files, and writes the output to 'output.jpg' if the request is successful.

JavaScript/TypeScript/Node (axios)

To access PresetBot with JavaScript, Typescript, or Node, you can use axios and the form-data library:

import fs from 'fs';
import FormData from 'form-data';
import axios from 'axios';
 
const url = "https://api.presetbot.com/preset/apply?output=jpeg&quality=80";
const apiKey = "YOUR_API_KEY";
 
const imageBuffer = fs.createReadStream('input.jpg');
const presetBuffer = fs.createReadStream('preset.xmp');
 
const formData = new FormData();
formData.append('image', imageBuffer);
formData.append('preset', presetBuffer)
 
axios.post(url, formData, {
  headers: {
    ...formData.getHeaders(),
    'x-api-key': apiKey
  },
  responseType: 'arraybuffer'
}).then(response => {
  fs.writeFileSync('output3.jpg', response.data);
  console.log('The image was processed and saved successfully!');
}).catch(error => {
  console.error('Failed to process the image:', error);
});

Ensure you have form-data and axios installed in your environment or install them:

npm install form-data axios

Replace "YOUR_API_KEY" with your actual API key from your dashboard. Also, ensure you specify the correct paths to the input files.

This script sends a POST request to the API endpoint, attaches the image and preset files, and writes the output to 'output.jpg' if the request is successful.

Remember to only access PresetBot on your server, so clients cannot access your API key!

JavaScript/TypeScript/Node (fetch)

To access PresetBot with JavaScript, Typescript, or Node, you can use fetch and the form-data library:

import fs from 'fs';
import fetch from 'node-fetch';
import FormData from 'form-data';
 
const url = "https://api.presetbot.com/preset/apply?output=jpeg&quality=80";
const apiKey = "YOUR_API_KEY";
 
const imagePath = 'input.jpg';
const presetPath = 'preset.xmp';
 
let imageStream = fs.createReadStream(imagePath);
let presetStream = fs.createReadStream(presetPath);
 
const form = new FormData();
 
form.append('image', imageStream, {
  filename: 'input.jpg',
  contentType: 'image/jpeg' // set the appropriate content type
});
 
form.append('preset', presetStream, {
  filename: 'preset.xmp',
  contentType: 'application/octet-stream'
});
 
fetch(url, {
  method: 'POST',
  headers: {
    'x-api-key': apiKey,
  },
  body: form
})
.then(async response => {
  if (!response.ok) {
    console.error(await response.text())
    throw new Error(`Server responded with status: ${response.status}`);
  }
  return response.arrayBuffer();
})
.then(data => {
  fs.writeFileSync('output3.jpg', Buffer.from(data));
  console.log('The image was processed and saved successfully!');
})
.catch(error => {
  console.error('Failed to process the image:', error);
});

Ensure you have the form-data and node-fetch libraries installed in your environment or install them:

npm install form-data node-fetch

Replace "YOUR_API_KEY" with your actual API key from your dashboard. Also, ensure you specify the correct paths to the input files.

This script sends a POST request to the API endpoint, attaches the image and preset files, and writes the output to 'output.jpg' if the request is successful.

Remember to only access PresetBot on your server, so clients cannot access your API key!


Rate Limits

We currently limit users to a rate of 10 requests / sec. These limits are put into place to prevent abuse and to prevent overloading our systems, but we are happy to bump this for reasonable use cases. If you need higher throughput, please contact us.


Billing

Each of our monthly plans include a number of megapixels processed through our endpoints. We only count requests where our servers successfully process your image.


Latency

Most requests are limited by the upload/download speed of images. Larger images will take a longer time to transfer. Processing times on our servers (excluding file transfers) are generally less than a couple seconds. If you have any questions about latency or want to talk to us about setting up dedicated infrastructure for your use case, please contact us.