Every web project eventually runs into the same problem: you need to resize an image, convert a format, maybe add some effects, or strip a background. You can set up ImageMagick, wrestle with Sharp, or build custom pipelines — or you can make one HTTP call.
That's why I built TheGlitch — a stateless image processing API that handles everything in a single request.
The Problem
Image processing infrastructure is surprisingly complex:
- Installing native dependencies on different OS targets
- Managing temporary files and disk cleanup
- Handling format quirks (AVIF support, GIF animation, color profiles)
- GPU acceleration for AI operations like background removal
- Scaling under load without leaking memory
I wanted an API where you send an image in and get a processed image out. Nothing stored, nothing cached on disk, no state between requests.
How It Works
TheGlitch processes images entirely in memory. The pipeline looks like this:
Input (URL/base64/binary/form)
→ Decode & Validate
→ Resize & Crop
→ Apply Effects
→ Format Convert
→ Return Binary
A single GET request can do everything:
curl "https://theglitch.p.rapidapi.com/api/v1/process?\
url=https://picsum.photos/1000&\
width=800&\
format=webp&\
brightness=10&\
contrast=15&\
sharpen=20" \
-H "X-RapidAPI-Key: YOUR_KEY" \
-H "X-RapidAPI-Host: theglitch.p.rapidapi.com" \
-o result.webp
Features
Resize & Crop — Four modes: fit (preserve aspect ratio), fill (crop to exact size), pad (add borders), stretch. Resolutions up to 8000x8000px.
Format Conversion — Input/output: JPEG, PNG, WebP, GIF, BMP, TIFF. Quality control per format.
7 Visual Effects — Brightness, contrast, saturation, blur, sharpen, grayscale, sepia. All combinable in one request.
AI Background Removal — GPU-powered, takes about 3 seconds per image. Returns transparent PNG.
14 Social Media Presets — Instagram square, Facebook cover, YouTube thumbnail, LinkedIn banner, and more. One parameter instead of remembering dimensions.
Code Examples
JavaScript:
const response = await fetch(
'https://theglitch.p.rapidapi.com/api/v1/process?url=IMAGE_URL&width=800&format=webp',
{ headers: { 'X-RapidAPI-Key': 'YOUR_KEY', 'X-RapidAPI-Host': 'theglitch.p.rapidapi.com' } }
);
const blob = await response.blob();
Python:
import requests
response = requests.get(
'https://theglitch.p.rapidapi.com/api/v1/process',
params={'url': 'IMAGE_URL', 'width': 800, 'format': 'webp'},
headers={'X-RapidAPI-Key': 'YOUR_KEY', 'X-RapidAPI-Host': 'theglitch.p.rapidapi.com'}
)
with open('result.webp', 'wb') as f:
f.write(response.content)
Why Stateless?
Every image is processed in memory and discarded after the response is sent. This means:
- GDPR compliant by design — no user data stored, ever
- No disk I/O bottleneck — everything happens in RAM
- Predictable scaling — each request is independent
- No cleanup jobs — nothing to garbage collect
Architecture Decisions
A few things I learned while building this:
SkiaSharp over ImageMagick — Native performance, cross-platform, no external dependencies. The tradeoff is less format support (no real AVIF encoding yet), but WebP covers most use cases.
Replicate for GPU ops — Instead of running my own GPU server, I proxy AI operations through Replicate. Background removal costs about $0.0014 per image with BiRefNet. Cold starts are free for public models.
Separate CPU and GPU rate limits — CPU operations (resize, effects, format) are cheap. GPU operations (background removal) are expensive. Different limits per plan make pricing fair.
Single VPS deployment — Docker Compose with Caddy as reverse proxy, Cloudflare in front for CDN/DDoS/SSL. Total infrastructure cost: under $6/month.
API Endpoints
| Endpoint | What it does |
|---|---|
/api/v1/process |
Full pipeline — resize + effects + format |
/api/v1/resize |
Resize only |
/api/v1/convert |
Format conversion |
/api/v1/effects |
Visual effects |
/api/v1/remove-bg |
AI background removal (GPU) |
/api/v1/optimize |
Auto-optimize for web (WebP) |
/api/v1/preset/{name} |
Social media presets |
Try It
The API is live with a free tier (500 requests/month). Check out the before/after examples on the website, or try it directly through RapidAPI:
- Website with live examples: theglitch.app
- API on RapidAPI: TheGlitch Image Processing
I'd love to hear what features you'd find useful. Background removal was the most requested during beta — what would you want next?
Top comments (0)