@tuzzle/url
v0.2.1
Published
Tuzzle media URL and transformation builder
Readme
@tuzzle/url
Pure, dependency-free builder for Tuzzle media delivery URLs and on-the-fly transformations. Works in any JS runtime (browser, Node, edge). No network calls.
bun add @tuzzle/url # or npm / pnpm / yarnUsage
import { createTuzzle } from '@tuzzle/url'
const tz = createTuzzle({ cdnUrl: 'https://cdn.tzzl.io', space: 'acme' })
// Options object
tz.url('photos/hero.jpg', { width: 800, format: 'webp', quality: 80 })
// => https://cdn.tzzl.io/acme/photos/hero.jpg?w=800&f=webp&q=80
// Fluent builder
tz.image('photos/hero.jpg')
.width(400)
.height(400)
.resize('fill')
.gravity('face')
.format('avif')
.toURL()
// => https://cdn.tzzl.io/acme/photos/hero.jpg?w=400&h=400&f=avif&r=fill&g=faceTransform options
| Option | Query | Values |
|---|---|---|
| width | w | positive int |
| height | h | positive int |
| format | f | jpeg png webp avif tiff gif pdf |
| quality | q | 1–100 (clamped) |
| resize | r | scale fit fill crop thumb |
| gravity | g | north … southwest, center, face, faces, eyes, auto |
Params are emitted in a stable order (w,h,f,q,r,g) for cache-friendly URLs. Undefined options are omitted.
