chop

An HTTP image server that resizes images on request and picks AVIF, WebP or the original format from the Accept header.

Open as Markdown

Serve one original image as many sizes and formats, from a URL, with no build step. chop reads originals from a folder, an HTTPS origin or an S3 bucket, resizes them with sharp, and picks AVIF, WebP or the source format from the Accept header of each request.

npx @wpelevator/chop --data /var/www/wp-content/uploads --port 8080
chop listening on http://0.0.0.0:8080, serving /var/www/wp-content/uploads

A browser that accepts AVIF and requests /2026/05/photo.jpg?w=300 gets a 300 pixel wide AVIF of the original. The quickstart shows the request and the response headers.

What you get

  • Resizing, cropping and padding from query arguments such as w, resize and lb, or from Cloudflare-style /cdn-cgi/image/ URLs. See Resize, crop and pad images and Migrate from Cloudflare Image Resizing.
  • AVIF or WebP when the client lists them in Accept, with Vary: Accept, a strong ETag and a one year Cache-Control. See Serve AVIF and WebP.
  • Read-only access. chop never writes to the data directory or any other directory, and with a data directory, the default, it makes no network requests.
  • Opt-in remote originals with safeguards: no redirects, checked addresses, a size cap and timeouts.
  • A command line server and a library with a request handler that doesn't depend on an HTTP framework. sharp is the only runtime dependency.

Authentication, URL signing and per-client rate limits belong to a CDN or a reverse proxy in front of chop.

Install

npm install @wpelevator/chop

Requires Node.js 22.12 or later. The examples use the bare chop command, which exists after the install. Before it, use npx @wpelevator/chop, because bare npx chop doesn't run this package. The container image is ghcr.io/wpelevator/chop, described in Run chop in Docker.

Pick a task

You want to Page
Try it in a minute Quickstart
Resize, crop or pad an image Resize, crop and pad images
Write a srcset and limit the widths Serve responsive images
Serve AVIF and WebP Serve AVIF and WebP
Set quality or remove metadata Set quality and strip metadata
Serve transparent PNGs and animated GIFs Serve transparent and animated images
Read originals from a folder, a site, S3 or named hosts Choose where originals come from, Serve images from S3
Expose a remote origin safely Secure remote origins
Run it in a container Run chop in Docker
Get ready for real traffic Prepare chop for production
Cache each variant once, with nginx or at a CDN Cache images, Cache with nginx
Fix an error Troubleshoot chop
Move from Photon or Cloudflare Image Resizing Migrate from Photon, Migrate from Cloudflare Image Resizing
Run the server and read its logs Run the server
Look up a setting or a status code Configuration, Responses and errors
Embed the handler in your own server Library API
See what changed in each release Changelog
Work on chop itself Development