Skip to content

Support HEIC image decoding in the /api/media/image proxy#404

Merged
techeng322 merged 3 commits into
mainfrom
techengme/myc-5015-support-heic-image-decoding-in-the-apimediaimage-proxy-so
Jul 11, 2026
Merged

Support HEIC image decoding in the /api/media/image proxy#404
techeng322 merged 3 commits into
mainfrom
techengme/myc-5015-support-heic-image-decoding-in-the-apimediaimage-proxy-so

Conversation

@techeng322

Copy link
Copy Markdown
Collaborator

Summary

  • Detect HEIC/HEIF buffers via ftyp brand sniffing and decode them to JPEG with heic-convert before passing to sharp.
  • Wire decoding into /api/media/image (imageProxyHandler) so Arweave-hosted HEIC blur/resize URLs no longer return 500.
  • Apply the same prepareImageBufferForSharp helper to OG collage thumbnails (getBase64Image).

Test plan

  • pnpm test:run src/lib/media/__tests__/isHeicBuffer.test.ts
  • pnpm test:run src/lib/media/__tests__/prepareImageBufferForSharp.test.ts
  • pnpm test:run src/lib/media/__tests__/imageProxyHandler.heic.test.ts
  • pnpm test:run src/lib/media/__tests__/imageProxyHandler.test.ts
  • pnpm test:run src/lib/og/__tests__/getBase64Image.heic.test.ts
  • Deploy and verify GET /api/media/image?url=ar://...&w=16&q=10&f=webp on a HEIC moment returns 200

Made with Cursor

sharp cannot read HEIC/HEIF from Arweave, which caused 500s on blur URLs
and broke OG image generation for Telegram-uploaded HEIC moments.

Co-authored-by: Cursor <cursoragent@cursor.com>
@vercel

vercel Bot commented Jul 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
in-process-api Ready Ready Preview Jul 11, 2026 5:50pm

Request Review

@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@techeng322, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 9 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 676dfea0-018c-4019-856f-fba1a97ba04c

📥 Commits

Reviewing files that changed from the base of the PR and between 5a7b76e and 24d0aa1.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (12)
  • package.json
  • src/lib/media/__tests__/imageProxyHandler.heic.test.ts
  • src/lib/media/__tests__/isHeicBuffer.test.ts
  • src/lib/media/__tests__/prepareImageBufferForSharp.test.ts
  • src/lib/media/decodeHeicToJpegBuffer.ts
  • src/lib/media/imageProxyHandler.ts
  • src/lib/media/isHeicBuffer.ts
  • src/lib/media/prepareImageBufferForSharp.ts
  • src/lib/media/readFtypBrands.ts
  • src/lib/og/__tests__/getBase64Image.heic.test.ts
  • src/lib/og/getBase64Image.ts
  • src/types/heic-convert.d.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch techengme/myc-5015-support-heic-image-decoding-in-the-apimediaimage-proxy-so

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

heic-convert decoding can exceed vitest's default 5s limit on slower runners.

Co-authored-by: Cursor <cursoragent@cursor.com>
@techeng322 techeng322 merged commit b5acd4f into main Jul 11, 2026
3 checks passed
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