Skip to main content

Find your next tool

Docs/API/Image API: compress, resize and convert
API

Image API: compress, resize and convert

Resize, crop, rotate, compress to a quality or a byte target, and convert images to JPG, PNG, WebP or AVIF in one pipeline call.

Short answer

POST /api/v1/pipeline/ with a sourceKey and a step {"operation":"image","pipeline":[…]} listing up to 8 operations: resize (maxWidth, maxHeight), crop (x, y, width, height), rotate (degrees), compress (quality 1–100 or targetBytes) and convert (jpg, png, webp, avif). For images already in My Documents use /documents/{documentId}/process/ with {"operation":"image","pipeline":[…]}.

Compress for the web

A typical product-photo pipeline caps the size and converts to WebP. In our test a 224 KB PNG became a 30 KB WebP at 400 px wide in about 4 seconds.

curl -X POST 'https://maxscanner.app/api/v1/pipeline/' \
  -H "Authorization: Bearer $MAXSCANNER_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{ "sourceKey": "users/<id>/media/inbox/…-photo.png", "steps": [ { "operation": "image", "pipeline": [ { "operation": "resize", "maxWidth": 1600 }, { "operation": "compress", "quality": 75, "format": "webp" } ] } ] }'

Hit a file-size target

Upload portals often demand "under 200 KB". Use compress with targetBytes instead of quality; the worker searches for the highest quality that fits. Targets must be between the minimum and maximum the API allows (up to 20 MB).

{ "operation": "image", "pipeline": [ { "operation": "resize", "maxWidth": 1200 }, { "operation": "compress", "targetBytes": 204800, "format": "jpg" } ] }

Chain image steps with PDF and OCR

Pipelines can continue after the image step: add {"operation":"convert","format":"pdf"} to wrap the result in a PDF, or {"operation":"ocr","format":"pdf"} to make it searchable. When the next step needs it, the image step outputs PNG automatically.

Frequently asked questions

Does compression strip metadata?

Re-encoded images do not keep EXIF data such as GPS location, which is usually what you want for public images.

Which format should I choose?

WebP for websites, JPG where compatibility matters most, PNG for screenshots and line art, AVIF for the smallest files when your audience uses modern browsers.

Related guides