·5 min read

Resize and Convert Images on the Fly with a REST API

Skip Sharp, Pillow, and ImageMagick. Resize, crop, and convert images to WebP, AVIF, PNG, or JPEG with a single POST request.

Image processing is one of the most common tasks in web development — and one of the most annoying to set up. Need to resize user-uploaded avatars? Generate thumbnails? Convert to WebP for performance? You're looking at Sharp, Pillow, ImageMagick, or libvips — each with native dependencies, platform quirks, and memory management concerns.

Or you can make one API call and move on.

The Problem with Local Image Processing

Here's what you're signing up for with a library-based approach:

  • Native dependencies — Sharp needs libvips, Pillow needs system libraries, ImageMagick needs... ImageMagick. All of these complicate Docker images and CI/CD pipelines.
  • Memory spikes — processing a 10MB image in a serverless function can blow your memory limit
  • Platform differences — what works on macOS might fail on Alpine Linux
  • Security surface — image processing libraries have had CVEs. Offloading to an API means you're not running untrusted image data through your own stack.

Image Processing via API

The API Snap Image Resize endpoint handles resizing, cropping, and format conversion in a single POST:

curl -X POST "https://api-snap.com/api/resize" \
  -H "Authorization: Bearer snp_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com/photo.jpg",
    "width": 400,
    "height": 300,
    "fit": "cover",
    "format": "webp"
  }' -o thumbnail.webp

Send a source image URL, specify your target dimensions and format, and get back the processed image. No installs, no native deps, no memory management.

Supported Output Formats

  • webp — best compression for web delivery (30-50% smaller than JPEG)
  • avif — next-gen format with even better compression
  • png — lossless, good for graphics and screenshots
  • jpeg — universal compatibility

Fit Modes

  • cover — fill the target dimensions, cropping as needed (great for thumbnails)
  • contain — fit within dimensions, preserving aspect ratio
  • fill — stretch to exact dimensions

Common Use Cases

User Avatar Thumbnails

When a user uploads a profile photo, resize it to a standard size before storing:

const thumbnail = await fetch("https://api-snap.com/api/resize", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.SNAPAPI_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    url: uploadedImageUrl,
    width: 200,
    height: 200,
    fit: "cover",
    format: "webp",
  }),
});
const buffer = Buffer.from(await thumbnail.arrayBuffer());
// Upload buffer to S3, R2, or your storage

E-commerce Product Images

Generate multiple sizes from one source: a 800px hero image, a 400px card image, and a 80px thumbnail. Three API calls, three sizes, zero config.

Blog and CMS Thumbnails

Auto-generate optimized WebP thumbnails when content authors upload images. Serve AVIF to browsers that support it for even better Core Web Vitals scores.

Performance and Pricing

Processing happens on the server, so your application stays lean. The free tier (100 calls/month) is enough to test your integration. For production use, the Pro plan handles 50,000 calls/month — enough for most apps with reasonable caching in front.

Pro tip: cache processed images in your CDN or object storage. Resize once, serve forever.

Get Started

Sign up for free, get your API key, and try the Image Resize endpoint in the Playground. Works from any language — Node, Python, Go, Ruby, or plain curl. Need to resize website screenshots? See our guide on building a thumbnail generator.

Ready to try it?

Get your free API key and start building in under a minute.