Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .changeset/website-hero-poster-resolution.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
"nostream-website": patch
---

perf(website): size the hero poster to the box it paints in

`hero-poster.webp` was encoded at 1920×1080 for a box `Hero.astro` caps at
1180×664 CSS px (`min(1180px, 80vw, film-h * 16/9)`), which Lighthouse's
`image-delivery-insight` reported as 36.9 KiB of waste on
`ema.tnsor.network` ([#876](https://github.com/cameri/nostream/issues/876)).
The poster now encodes at 1440×810 — 1.22× that box, enough for a 1.25×
display, so it needs no `devicePixelRatio` branch — and drops from 42,926 B
to 30,878 B, a 28% reduction. SSIM against the old file at the display size
is 0.9968 at 1180×664 and 0.9964 at the larger 1359×764 layout #876 measured.

The social preview is unaffected: `og:image` defaults to the generated
`social-card.png` at 1200×630 in `build-social-card.mjs`, and the hero poster
has no second consumer. `scripts/build-media.mjs` resizes to 1440 so the next
`pnpm run media` keeps the size instead of restoring 1920.
Binary file modified website/site/public/media/hero-poster.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 7 additions & 1 deletion website/site/scripts/build-media.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,15 @@ if (existsSync(planet)) {
console.warn('skip planet: run `pnpm run assets` in website/hero-animation first')
}

// Page-sized, not film-sized: Hero.astro caps the film at `min(1180px, 80vw,
// film-h * 16/9)`, so the poster paints in at most 1180x664 CSS px and 1440x810
// is 1.22x that box - enough for a 1.25x display, and no devicePixelRatio
// branch. (#876 measured 1359x764, the layout before that cap landed in #899.)
// The social preview is `social-card.png`, generated at 1200x630 by
// build-social-card.mjs, and never this file.
const landingPoster = path.join(LANDING, 'frames', LANDING_POSTER)
if (existsSync(landingPoster)) {
await sharp(landingPoster).resize(1920).webp({ quality: 90 }).toFile(path.join(MEDIA, 'hero-poster.webp'))
await sharp(landingPoster).resize(1440).webp({ quality: 90 }).toFile(path.join(MEDIA, 'hero-poster.webp'))
Comment thread
chappie-daemon marked this conversation as resolved.
Resolved
console.log('hero poster → public/media')
} else {
console.warn(`skip hero poster: run \`pnpm run frames\` in website/hero-animation (need frames/${LANDING_POSTER})`)
Expand Down
Loading