Developer Docs

TL;DR: One conversion endpoint to rule them all.

Try it out

Width
Format

Final Conversion URL

Endpoints

Converting Images

GET https://api.picturething.com/convert/{options}/{url}

Converts and processes images with various options.

  • options: A comma seperated string of key=value pairs. See below for conversion options
  • url: The URL of the remote you want to convert. Use URL-encoding.

Authentication

To authenticate against any endpoint pass the API token as a header or as a query string parameter.

Authorization: Bearer APITOKEN

or

https://api.picturething.com/convert/width=800,format=webp/https%3A%2F%2Fexample.com%2Fimage.jpg?key=APITOKEN

Image Conversion Options

Note that aspect ratio is always preserved regardless of the mode.

OptionTypeDescriptionValid Values
Basic Options
widthintegerSet output image width1-4096 pixels
heightintegerSet output image height1-4096 pixels
formatstringOutput image formatjpeg, jpg, png, webp
qualityintegerImage quality1-100
dprfloatDevice pixel ratio0.1-4.0
Image Processing
blurintegerApply Gaussian blur1-250
brightnessfloatAdjust brightness0.1-10.0
contrastfloatAdjust contrast0.1-10.0
saturationfloatAdjust color saturation0.1-10.0
sharpenfloatApply sharpening0.1-10.0
backgroundstringSet background color for transparent imagesHex color code without # (e.g. FF0000 or F00)
animbooleanPreserve animation framestrue/false
Image Transformations
fitstringAffects interpretation of width and height. All resizing modes preserve aspect ratio.scale-down: Similar to contain, but image is never enlarged. If image is larger than given dimensions, it will be resized. Otherwise original size is kept.
contain: Image will be resized to be as large as possible within given dimensions while preserving aspect ratio. If only one dimension is provided, image will match that dimension exactly.
cover: Resizes to fill entire area of width and height. If aspect ratio differs, image will be cropped to fit.
crop: Image will be shrunk and cropped to fit within specified dimensions. Image will not be enlarged. For smaller images, same as scale-down. For larger images, same as cover.
flipstringFlip image orientationh: Flip horizontally.
v: Flip vertically.
hv: Flip both horizontally and vertically
gravitystringControl image positioningBasic positions: left, right, top, bottom, topleft, topright, bottomleft, bottomright, center, auto. Coordinates: x,y values (e.g. 0.5x0.5 for center)
rotateintegerRotate image0-360 degrees
trimstringRemove surrounding backgroundFormat: “top;right;bottom;left” (e.g. 10;20;10;20)

Error Handling

The API will return validation errors for:

  • Invalid option formats (must be key=value)
  • Unknown options
  • Values outside the allowed ranges
  • Invalid formats for specific options
  • Malformed input

Examples

Valid options:

width=800,height=600,format=webp
quality=80,dpr=2.0
fit=cover,gravity=center
background=#FF0000
trim=10;20;10;20

Invalid options:

width=5000  // Exceeds maximum width
format=gif  // Invalid format
background=red  // Not a hex color
trim=10,20,10,20  // Wrong separator

Conversion Credits

The same image with the same conversion setting is cached so does not cost another conversion credit.