ForHosting KIT · Images

Compress an image

Every uncompressed image sitting on a page is bytes a visitor has to download before they see anything. This endpoint recompresses a JPEG or PNG down to a smaller footprint while keeping the picture looking the same to the eye, so a gallery of five hundred photos stops being the reason a page loads slowly.

● StablePer request + per image$0.002
Use it from WebAPIEmailApp soonTelegram soon

Run this on our servers with your account. Free tools run in your browser; this one bills your KIT balance per the price above.

Why file size quietly matters

A photo straight off a camera or phone often carries far more data than a screen needs to display it — color information, metadata and encoding overhead that add weight without adding visible detail. That extra weight shows up directly in page load time, mobile data usage and hosting cost, which is why compression is one of the few optimizations that pays for itself immediately.

Who runs images through compression

Online stores with thousands of product photos where load time affects conversion; publishers whose article images make up most of a page's weight; app backends that accept user uploads at full camera resolution and need to store something lighter. Anywhere images are served to real visitors on real connections, compression is the step between a raw upload and a page that loads fast.

What happens to your image

You post the source file, we return a task_id right away, and the job compresses it — reducing file size while preserving visual quality — without changing its dimensions or format. Once it's ready you're notified by signed webhook, or you fetch the compressed image from a signed link valid for 24 hours.

Fitting it into an upload pipeline

Because it's async and billed only on success, compression slots in right after upload without adding a visible delay for the user: the original is accepted, a compression request fires in the background, and the lighter version replaces it once the webhook confirms it's ready. A batch of thousands of legacy images works the same way, submitted in parallel and collected as each one finishes.

A brief note on how compression works

JPEG has used lossy compression since the format was standardized in 1992, discarding detail the eye is least likely to notice in exchange for a much smaller file; PNG, arriving a few years later, compresses losslessly instead, shrinking file size without discarding any pixel data at all. Because the two formats trade off differently between size and fidelity, compressing them well means applying the right technique to each rather than treating every image the same way regardless of what it's used for.

Product catalog optimization

An online store compresses every product photo on upload so category pages load faster without visibly softer images.

Article image pipelines

A publishing platform compresses hero and inline images automatically, cutting page weight without a human reviewing each photo.

Mobile app uploads

A backend compresses user-submitted photos before storing them, reducing storage cost across millions of uploads.

Legacy media cleanup

A media library runs a one-time batch to compress thousands of old uncompressed images without re-touching them individually.

Is the Image Compression API available now?

Yes, it's live at POST /image/compress with the pricing below already in effect.

How is it priced?

$0.002 per request plus $0.005 per image, published and the same whether you compress one photo or a hundred thousand.

Does compression change the image dimensions?

No, only the file size changes; width and height stay exactly as the source image had them.

Will the image look visibly different?

Compression is tuned to reduce file size while preserving visual quality, so the result should look effectively the same at normal viewing sizes.

Which formats can I compress?

JPEG and PNG are supported, each compressed with the technique appropriate to its format — lossy for JPEG, lossless for PNG.

Is it a free API?

There's no free tier — free tiers get abused and slow everyone down. Access runs on a prepaid ForHosting KIT balance: top up from $10.00 (it never expires) and each request is charged at its published price, so a call with no balance returns HTTP 402. No subscription, no tokens, no invented credits, and a failed task is never charged.

How do I get the compressed image?

By signed webhook when the job finishes, or via a signed link that stays valid for 24 hours.

Am I charged if compression fails?

No. Failed tasks retry automatically up to three times and are never billed; you get a clear error instead.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/image/compress

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, and soon from our app, email and Telegram.

curl -X POST https://api.kit.forhosting.com/image/compress \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"image":"https://ejemplo.com/imagen.jpg"}'
{
  "image": "https://ejemplo.com/imagen.jpg"
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "image.compress",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002
Per image$0.005

Published price — no tokens, no invented credits. A failed task is never charged.

max_mb15
max_megapixels12
HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Read the full KIT documentation →