# Image compressor

> Shrink JPEG, PNG, WebP, and AVIF in the browser, with the real before and after size.

Free image compressor. Set a quality level, optionally cap the long edge, and compress a batch of JPEG, PNG, WebP, or AVIF files. You see the size before and after, the savings, and you can download a ZIP. The work stays on this device.

- Page: https://benchline.fabwaseem.com/t/image-compress
- Runs: in the browser. Input stays on the device.
- Price: free, no account
- Input: Images, a quality from 1 to 100, an optional max edge in pixels, and a target format.
- Output: Compressed images with before and after byte sizes, the savings, and a ZIP for the batch.
- Keywords: image compressor, compress image, compress jpeg, webp compressor, avif compressor
- Updated: 2026-10-18
- Built by: Waseem Anjum (https://fabwaseem.com)

## How to use it

1. **Drop a batch.** Add the images you want to shrink. The original size shows on each row.
2. **Set quality and a max edge.** Quality applies to JPEG, WebP, and AVIF. Max edge is optional and keeps the aspect ratio.
3. **Compare the sizes and download.** Each row shows the new size and the percent saved. Download one file or a ZIP.

## Use it from an AI agent

MCP tool name: `compress_image`
MCP endpoint: https://benchline.fabwaseem.com/mcp (Streamable HTTP, no key)
HTTP: POST https://benchline.fabwaseem.com/api/v1/tools/image-compress with the input as the JSON body
This call fetches a public URL on the server. Private addresses are refused.

Re-encode an image at a quality from 1 to 100, optionally capping the longest edge. Send base64 or a public URL. Private addresses are refused and the decoded file is capped at 10 MB. Returns the image as base64.

### Input schema

```json
{
  "type": "object",
  "properties": {
    "file": {
      "type": "object",
      "properties": {
        "url": {
          "description": "Public http or https URL. Private and local addresses are refused.",
          "type": "string"
        },
        "data": {
          "description": "Base64 bytes or a data URI. Decoded size is capped at 10 MB.",
          "type": "string"
        },
        "mimeType": {
          "description": "MIME type when you know it.",
          "type": "string"
        },
        "filename": {
          "description": "File name, including the extension when you have one.",
          "type": "string"
        }
      },
      "additionalProperties": false,
      "description": "The image. Provide url or data."
    },
    "choice": {
      "default": "original",
      "type": "string",
      "enum": [
        "original",
        "jpeg",
        "png",
        "webp",
        "avif"
      ]
    },
    "quality": {
      "default": 80,
      "type": "number"
    },
    "maxEdge": {
      "default": null,
      "description": "Longest edge in pixels. Omit it to keep the size.",
      "anyOf": [
        {
          "type": "number",
          "exclusiveMinimum": 0
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "required": [
    "file",
    "choice",
    "quality",
    "maxEdge"
  ],
  "additionalProperties": false
}
```

### Example tools/call

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "compress_image",
    "arguments": {
      "file": {
        "url": "https://example.com/file"
      },
      "choice": "original",
      "quality": 80,
      "maxEdge": null
    }
  }
}
```

Setup for Claude, Cursor, and VS Code: https://benchline.fabwaseem.com/mcp/guide

## Questions

### Are the images uploaded?

No. Compression runs in this browser. The original file is not sent anywhere.

### What does the quality slider do?

It sets lossy quality from 1 to 100 for JPEG, WebP, and AVIF. Lower numbers are smaller and softer. PNG is lossless, so the slider does not change a PNG unless you also cap the long edge or switch format.

### Why did the file get larger?

A high quality setting, or turning a small PNG into a heavy JPEG, can grow the file. The before and after numbers are the real byte counts, including when the result is larger.

### Can I limit the pixel size?

Yes. Max edge is the longest side in pixels. The other side follows the aspect ratio. Leave it empty to keep the original dimensions.

### How do I download a batch?

Compress, then save one file from its row or download a ZIP of every finished image.

## Related tools

- [Image format converter](https://benchline.fabwaseem.com/t/image-convert): Convert HEIC, WebP, PNG, JPG, and AVIF in the browser. Nothing is uploaded.
- [Image resizer](https://benchline.fabwaseem.com/t/image-resize): Resize by pixels or percent, with the aspect ratio locked and a batch ZIP.
- [Color converter](https://benchline.fabwaseem.com/t/color-converter): Turn any color into HEX, RGB, HSL, OKLCH, and CMYK, and check the contrast ratio.
- [OG image generator](https://benchline.fabwaseem.com/t/og-image-generator): Pick a template, watch the card update, then download the PNG or copy the Next.js file.
