nnesly

Images

Ask a static site for the image size you will actually display, and that is what gets downloaded.

A 2400-pixel screenshot shown in a 320-pixel card still costs the visitor the whole file. On a static site, nesly can resize and re-encode that image as it is served. Add the size to the image's own address:

<img src="/hero.png?w=640" alt="" />

There is nothing to install, import or switch on. The source file on your site is never changed — each variant is produced when it is asked for and kept in the edge's cache.

What you can ask for

ParameterValuesMeaning
w1–4096Width in pixels. The height follows, keeping the aspect ratio.
h1–4096Height in pixels. On its own, the width follows.
fitcontain · coverOnly meaningful with both w and h. contain fits inside the box, cover fills it and crops around the centre. Default: contain.
q1–100Quality, for whichever request already produces a new image — a resize or a format change. Default: 82.
formatauto · webp · jpeg · pngauto sends the smallest format the visitor's browser can read — WebP where it is supported, otherwise JPEG, or PNG when the image has transparency. Left out, the format stays as it is.

These work together, so a card thumbnail is one address: /hero.png?w=400&h=300&fit=cover. They also work in srcset, which is how a browser picks the right one for the screen it is on.

What it will not do

  • It never enlarges. Asking an 800-pixel file for 2000 gives you the 800-pixel file, not a blurred copy of it.
  • It never breaks an image that worked. A file it cannot read, an animated GIF, or an image past the size it will process is sent exactly as you uploaded it. There is no error page on this path.
  • It leaves other addresses alone. Only the parameters above mean anything; a cache-busting ?v=3 changes nothing.
  • Static sites only. Responses from your own running application are passed through untouched — nesly does not read into them.

Formats

PNG, JPEG, GIF and WebP are read; WebP, JPEG and PNG are written.

format=auto is usually the single biggest saving, and it never sends a format the visitor cannot read: browsers that support WebP get WebP, the rest get JPEG, and an image with transparency keeps its alpha either way. On the smooth, interface-shaped images most sites actually serve — screenshots, charts, flat illustrations — WebP is dramatically smaller than the same picture as a JPEG. On a noisy photograph the two are close, because there is little left to compress.