---
title: "IMG Processing"
year: "2024"
motto: "Image Processing API"
description: "Image Processing API that helps to integrate powerful image processing capabilities into your applications in minutes."
stack: ["javascript", "typescript", "nodejs", "python", "react", "nextjs", "hono", "cloudflare"]
website: "https://img-processing.com"
url: "https://rolandoandrade.me/projects/img-processing/"
author: "Rolando Andrade"
---

# IMG Processing

> Image Processing API

Image Processing API that helps to integrate powerful image processing capabilities into your applications in minutes.

Year: 2024. Stack: javascript, typescript, nodejs, python, react, nextjs, hono, cloudflare. Website: https://img-processing.com

Every developer hits this problem at some point. You need to resize images, remove backgrounds or add watermarks. You search online, find a dozen libraries, spend hours connecting them, and learn that half do not work the way you expected. Then you need a server with enough computing power to process images. The work never seems to end.

I built IMG Processing because I was tired of solving the same problem again and again. It is a REST API. You upload an image and get back exactly what you need. No servers to manage, no fights with dependencies.

## Five kinds of operations

IMG Processing covers the image operations developers need most:

- Storage: unlimited image hosting with direct URLs.
- Transformations: resize, crop, rotate and mirror.
- Editing: background removal, blur and color modulation.
- Analysis: image classification, OCR text extraction and visual questions and answers.
- AI generation: create images from text prompts.

The API follows REST conventions. You send an API key in the header and get JSON responses.

```bash
curl -X POST https://api.img-processing.com/v1/images/upload \
  -H "x-api-key: YOUR_API_KEY" \
  -F "file=@image.jpg" \
  -F "name=my-image"
```

## Built on Cloudflare's edge

The whole platform runs on Cloudflare's edge network, servers spread around the world close to users. I chose it on purpose, for both speed and cost.

The core stack has four parts:

- Hono, a small web framework made for edge runtimes.
- Cloudflare Workers, serverless code that runs at the edge.
- D1, a SQLite database on Cloudflare, used through the Prisma ORM.
- R2, object storage for the images, with two buckets: one private and one public.

The code is organized by feature. Access, analysis, creation, edition, transformation and batch operations each live in their own module. Related code stays together, and adding a new image operation is simple.

## Image processing with WebAssembly

Libraries like Sharp need native bindings, which do not work in serverless environments. So I use **@cf-wasm/photon**, a WebAssembly port of the Photon image library. WebAssembly is a compact code format that runs in the same sandbox as JavaScript, almost as fast as native code.

In Workers, operations like resize, crop and color changes take milliseconds, with no cold starts. The Lanczos resampling algorithm gives high quality results, which matters most when you shrink photographs.

## AI for analysis and generation

The analysis and generation features use several AI services.

Cloudflare AI handles classification and visual question answering right at the edge. Basic inference needs no outside API calls.

AWS Textract powers OCR text extraction. It handles complex layouts, tables and handwriting better than simpler options.

Google GenAI generates the images. Users write a prompt, and the model creates a 1024x1024 image.

![Image generated using the /imagine endpoint](https://storage.rolandoandrade.me/blog/cat-generated-image.webp)

Background removal uses a segmentation model that separates the foreground from the background. Its quality competes with RemoveBG at a fraction of the cost.

![Background removal result](https://storage.rolandoandrade.me/blog/remove-bg-result.webp)

## A generated TypeScript SDK

Beyond the REST API, I ship a Node.js SDK generated with [Stainless](https://www.stainless.com/). Stainless reads the OpenAPI specification, the file that describes every endpoint, and writes natural TypeScript code from it.

```typescript
import ImgProcessing from 'img-processing-sdk';

const client = new ImgProcessing({
  apiKey: process.env.IMG_PROCESSING_API_KEY,
});

// Upload an image
const image = await client.images.upload({
  image: fs.createReadStream('/path/to/photo.jpg'),
  name: 'product-photo'
});

// Remove background
const result = await client.images.edition.removeBackground(image.id);
```

The SDK handles authentication, retries, file uploads and response parsing. Its TypeScript types give you autocomplete and catch mistakes before the code runs.

## Workspaces for teams

The platform supports workspaces so teams can work together. Each workspace has its own:

- API keys (test and live)
- Image storage quota
- Billing and subscription
- Member access controls

Clerk handles authentication: signup, login and sessions. The `@hono/clerk-auth` middleware checks the token on every request.

## Rate limits and plans

Cloudflare's built in rate limiting protects the API from abuse. Stripe handles subscriptions with three plans: Hobby, Pro and Enterprise. Each plan raises the rate limits and removes watermarks from processed images.

Test API keys add watermarks, and their images expire after 90 days. In exchange, test operations do not count against the quota. Developers can build a prototype without giving payment details.

## Docs you can try

The documentation uses Scalar for an interactive API reference. Users can test endpoints right in the browser. The playground cut support questions a lot. Seeing a request work teaches more than reading about one.

![Interactive API playground](https://storage.rolandoandrade.me/blog/img-processing-playground-request.webp)

## Works for everyone

Building an API product taught me the gap between "works for me" and "works for everyone". With many different users, the edge cases multiply.

The D1, R2 and Workers stack keeps costs very low. I pay a fraction of what traditional cloud servers would cost, and it is faster, because everything runs at the edge.

The SDK generator changed how I work. Writing client libraries by hand is slow and easy to get wrong. When they are generated from OpenAPI, the SDK always matches the API.

[https://img-processing.com](https://img-processing.com)

* * *

If you are building something that needs image processing, give it a try. The free tier is generous enough for prototyping.

[Book a call with Rolando](https://rolandoandrade.me/pricing/)
