Skip to content

Send HEIC straight to the browser decoder - #19

Merged
farhanmasud merged 1 commit into
stagingfrom
fix/heic-straight-to-browser
Nov 7, 2026
Merged

farhanmasud merged 1 commit into
stagingfrom
fix/heic-straight-to-browser

Conversation

@farhanmasud

Copy link
Copy Markdown
Member

Follow-up from checking staging. In Chrome and Firefox, adding a HEIC logged three VIPS-WARNING: error in tile lines in the console. libvips recognises the HEIF container but has no HEVC decoder, so it failed partway through decoding before the browser fallback ran. The warnings were console-only; users saw the right message.

Change

  • src/lib/heif.ts reads the file's first 256 bytes (the ftyp box). If the brands mark it as HEVC-coded HEIF (heic, heix, hevc, …), it skips libvips and goes straight to the browser decoder.
  • AVIF, which is also HEIF but AV1-coded, still goes to libvips, as before.
  • Safari opens HEIC a little sooner, since it no longer waits for libvips to fail first.
  • Chrome and Firefox show the same message as before, with nothing in the console.
  • The HEIC message is now chosen by content as well as name, so a HEIC named .jpg gets "This browser can’t open HEIC…" instead of "Can’t read this file".

Tests

  • Unit: the brand check covers:
    • HEIC as the major brand
    • HEIC only in the compatible list (as in libheif's sample)
    • AVIF
    • brands just past the box
    • JPEG and short reads
  • e2e: a HEIC header named photo.jpg gets the HEIC message, with no console errors. It fails without the fix.
  • By hand: libheif's sample HEIC (the one from the Android test) logs nothing on this branch. Production logs the three warnings.

🤖 Generated with Claude Code

https://claude.ai/code/session_01STHRjFYWhkJBxSKG3tJdap

libvips recognises HEIF but has no HEVC decoder, so trying it first only
cost time and logged three "VIPS-WARNING: error in tile" lines. The file's
ftyp brands now decide: HEVC-coded HEIF skips libvips. AVIF, also HEIF,
still goes to libvips. The same check picks the HEIC message, so a HEIC
named .jpg gets it too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01STHRjFYWhkJBxSKG3tJdap
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Deploying image-optimizer with  Cloudflare Pages  Cloudflare Pages

Latest commit: 6028769
Status: ✅  Deploy successful!
Preview URL: https://0dd9480e.image-optimizer-7ba.pages.dev
Branch Preview URL: https://fix-heic-straight-to-browser.image-optimizer-7ba.pages.dev

View logs

@farhanmasud
farhanmasud merged commit 9972967 into staging Nov 7, 2026
2 checks passed
@farhanmasud
farhanmasud deleted the fix/heic-straight-to-browser branch November 7, 2026 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant