What it does
Make PDFs and JPEG, PNG, WebP, GIF, TIFF, BMP or AVIF images smaller at Low, Medium, Aggressive Lossless or Aggressive Max. A PDF can aim for the exact size you need; an image comes back in its own format, at the same size.
It reads one AVIF, BMP, GIF, JPEG, JPG, PDF, PNG, TIF, TIFF or WEBP file. You get: a smaller file in the same format, never larger than the one you sent.
Step by step on the website
Use Compress
Open Compress on the website.
Open CompressAdd your PDFs and images, together if you like: drop them on the page or choose them (up to 100 MB each on a free run).
Choose Low, Medium, Aggressive Lossless or Aggressive Max. For a PDF you can also choose Custom size and enter the size you need, or turn on Optimise for fast web view.
Select Compress, then download each smaller file and see how much you saved.
Settings
Every setting, with the name the page shows and the name the API uses. On the page: shown next to your file. More options: under More options. API only: not offered on the website.
| Setting | API name | Choices or values | Default | Where | What it does |
|---|---|---|---|---|---|
| Profile | profile | Low (best), Medium (medium), Aggressive Lossless (aggressive_lossless), Aggressive Max (aggressive_max) | Low | On the page | How hard to compress. |
| Optimise for fast web view | fastWebView | On (true), Off (false) | Off | On the page | A browser shows the first page while the rest is still downloading. |
| Target size | targetSize | 0.01 to 2097152 | On the page | A size to aim for, in the unit beside it. | |
| Unit | targetUnit | KB (kb), MB (mb) | MB | On the page | The unit of the target size. |
| Tolerance | targetSizeTolerancePercent | 5 to 10% | 7.5 | More options | How far above the target still counts as reaching it. |
| Image details | metadata | Keep details (keep), Strip details (strip) | Keep details | More options | Images only. Keep copies the camera and editing details; Strip removes them but keeps the orientation and colour profile. |
| File name | outputName | Text | More options | Optional. The extension is added for you. |
Run it with the API
Upload your file with POST /api/v2/documents, then start Compress with POST /api/v2/document-operations and toolId compress-pdf. The parameters use the API names in the settings table; anything you leave out takes its default. Read the operation until its state is completed, then download the output version.
The request below uses the same starting settings as the website. The script after it does the whole journey: upload, run, wait and download.
{
"documentId": "doc_8kq2W1",
"versionId": "ver_3Jx9Lm",
"toolId": "compress-pdf",
"parameters": {
"profile": "medium"
},
"idempotencyKey": "compress-pdf-2026-11-22-1"
}#!/usr/bin/env bash
# Needs curl and jq.
# Your API key: set WELLFRIEND_API_KEY, or replace YOUR_API_KEY (keys: https://wellfriend.dev/dashboard/developer-api/keys).
set -euo pipefail
API="${WELLFRIEND_API_URL:-https://wellfriend.dev}"
WELLFRIEND_API_KEY="${WELLFRIEND_API_KEY:-YOUR_API_KEY}"
AUTH="Authorization: Bearer $WELLFRIEND_API_KEY"
RUN=$(uuidgen) # reuse this value to retry safely
# upload FILE CONTENT_TYPE KEY: prints the document id and its version id
upload() {
curl -sS --fail-with-body -X POST "$API/api/v2/documents" -H "$AUTH" -H "Idempotency-Key: $3" \
-H "Content-Type: $2" -H "X-Wellfriend-Filename: $(basename "$1")" --data-binary "@$1" \
| jq -r '"\(.document.id) \(.document.currentVersion.id)"'
}
read -r DOCUMENT_ID VERSION_ID < <(upload 'input.pdf' 'application/pdf' "$RUN-upload")
# Run compress-pdf
OP=$(jq -n --arg doc "$DOCUMENT_ID" --arg ver "$VERSION_ID" --arg key "$RUN-1" \
--argjson parameters '{"profile":"medium"}' \
'{documentId: $doc, versionId: $ver, toolId: "compress-pdf", parameters: $parameters, idempotencyKey: $key}' \
| curl -sS --fail-with-body -X POST "$API/api/v2/document-operations" -H "$AUTH" \
-H "Content-Type: application/json" -H "Idempotency-Key: $RUN-1" --data-binary @- | jq -r .operation.id)
while :; do
RESULT=$(curl -sS --fail-with-body "$API/api/v2/document-operations/$OP" -H "$AUTH")
STATE=$(echo "$RESULT" | jq -r .operation.state)
case "$STATE" in completed) break ;; failed|cancelled|canceled) echo "$RESULT" >&2; exit 1 ;; esac
sleep 1
done
DOCUMENT_ID=$(echo "$RESULT" | jq -r .operation.outputDocumentId)
VERSION_ID=$(echo "$RESULT" | jq -r .operation.outputVersionId)
# Download the result
curl -sS --fail-with-body "$API/api/v2/documents/$DOCUMENT_ID/versions/$VERSION_ID/content" -H "$AUTH" -o 'input-wellfriend.pdf'Run it with the SDKs
The SDKs upload the file, run compress-pdf with the same parameters and wait for the result: wf.tools.compressPdf() in TypeScript, wf.tools.compress_pdf() in Python, wf.Tools.CompressPDF() in Go.
// wellfriend-document-sdk: npm install wellfriend-document-sdk@latest. An ES module (top-level await): save it as .mts.
// Your API key: set WELLFRIEND_API_KEY, or replace YOUR_API_KEY (keys: https://wellfriend.dev/dashboard/developer-api/keys).
import { Wellfriend } from "wellfriend-document-sdk";
const wf = new Wellfriend({ apiKey: process.env.WELLFRIEND_API_KEY ?? "YOUR_API_KEY" });
const result = await wf.tools.compressPdf("input.pdf", { profile: "medium" });
await result.save("input-wellfriend.pdf");# wellfriend-document-sdk: pip install -U wellfriend-document-sdk
# Your API key: set WELLFRIEND_API_KEY, or replace YOUR_API_KEY (keys: https://wellfriend.dev/dashboard/developer-api/keys).
import os
from wellfriend import Wellfriend
wf = Wellfriend(api_key=os.environ.get("WELLFRIEND_API_KEY", "YOUR_API_KEY"))
result = wf.tools.compress_pdf("input.pdf", profile="medium")
result.save("input-wellfriend.pdf")// go get wellfriend.dev/go/wellfriend@latest
package main
import (
"context"
"fmt"
"os"
"wellfriend.dev/go/wellfriend"
)
func main() {
if err := run(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
func run() error {
// Your API key: set WELLFRIEND_API_KEY, or replace YOUR_API_KEY (keys: https://wellfriend.dev/dashboard/developer-api/keys).
apiKey := os.Getenv("WELLFRIEND_API_KEY")
if apiKey == "" {
apiKey = "YOUR_API_KEY"
}
wf := wellfriend.New(wellfriend.WithAPIKey(apiKey))
ctx := context.Background()
res, err := wf.Tools.CompressPDF(ctx, wellfriend.File("input.pdf"), &wellfriend.CompressPDFParams{Profile: wellfriend.Ptr(wellfriend.CompressPDFProfile("medium"))})
if err != nil {
return err
}
return res.Save(ctx, "input-wellfriend.pdf")
}