The set of variants — keepix.cloud Skip to content

Variants

The set of variants

The set is named and finite. There is no arbitrary width — and that is a decision, not a simplification: ?w=473 is both a cache explosion and a free way to occupy the machine's processor.

Try it

Which variant does a block need?

Set the width of the block on the page and the screen density. The smallest variant that still covers the pixels is the right one.

  • thumb400 px wide
  • card1 000 px wide
  • full1 400 px wide

Serve:

Images

NameWidthFormatWhat for
thumb400 pxWebP, quality 82lists, tiles, avatars
card1000 pxWebP, quality 82a product card, the main storefront
full1400 pxWebP, quality 82full-screen viewing

Video

NameWhat it isFormat
postera still frame, taken at 10% of the duration — no earlier than second 0.5 and no later than second 3WebP up to 1280 px
previewa silent clip of the first secondsMP4 640 px
hlsthe main playback path, up to three quality stepsHLS, H.264 + AAC
mp4a fallback for older clientsprogressive MP4 1280 px

The HLS steps are 640, 1280 and 1920 px. A step wider than the original is not made: a stretched copy looks like our fault.

Two rules under which a variant may not appear

We do not stretch

If the original is narrower than the variant's width, the variant stays at the original's size, and the answer says so honestly — the w and h fields carry the real numbers.

Identical copies are not stored twice

If two widths would come out as the very same file, the second address is not created. Two byte-identical files at two addresses are two downloads of the same thing onto someone's phone.

POST /api/v1/put?kind=prodimg&key=42&variants=card,full   ← original 300×200
    → {
        "ow": 300, "oh": 200,
        "variants": { "card": { "w": 300, "h": 200, … } },
        "skipped":  { "full": "the original is 300 px wide — the variant would be byte-identical to “card”" }
      }

So the set of variants in the answer always has to be read, not assumed: you asked for two and may have got one, and that is a normal, expected answer.

How a new variant is added

A new variant appears in the service configuration and at the tenant in the same task. Adding it “on the service only” makes no sense: the address is learnt from the answer anyway, and an unrequested variant would simply take up space.

Objects already uploaded can be rebuilt into a new variant without sending the file again — the original is kept in our cold tree and is never served outward. That is what it is kept for.