Skip to content

tools/ui: Add HEIC/HEIF image support#24137

Open
NickM-27 wants to merge 3 commits into
ggml-org:masterfrom
NickM-27:heic-image-support
Open

tools/ui: Add HEIC/HEIF image support#24137
NickM-27 wants to merge 3 commits into
ggml-org:masterfrom
NickM-27:heic-image-support

Conversation

@NickM-27
Copy link
Copy Markdown

@NickM-27 NickM-27 commented Jun 4, 2026

Overview

This PR implements support for HEIC/HEIF images in the UI, matching how WebP is implemented. An additional dependency for heic-to is added as non-safari browsers don't have the capability to decode HEIC images directly.

closes #24103

Requirements

@NickM-27 NickM-27 requested a review from a team as a code owner June 4, 2026 18:26
Comment thread tools/ui/package.json Outdated
"eslint-plugin-storybook": "10.2.4",
"eslint-plugin-svelte": "3.15.0",
"globals": "16.3.0",
"heic-to": "1.5.2",
Copy link
Copy Markdown
Contributor

@ngxson ngxson Jun 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO I'm not really a fan of adding a 3MB library to do such a simple task.

Can we simply draw it to a canvas then convert back to jpeg?

Image

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately the non Safari browsers don't support decoding the image, so some library is needed to convert. I'll do some shopping around to see if there is a more lightweight option.

Copy link
Copy Markdown
Author

@NickM-27 NickM-27 Jun 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most options are similar because they rely on the libheif WASM to do the decoding. I tried using https://github.com/saschazar21/webassembly/tree/master/packages/heif but this fails on many of the HEIC images I have. It seems like if this is a goal to support this image type a library will be required.

I found one other library option I am looking into that might work, but besides that it seems a way to improve this is to potentially try and lazy load the dependency only when it is needed

Copy link
Copy Markdown
Contributor

@ngxson ngxson Jun 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that is not much better, the lib is ~2MB and wasm version is ~1MB (raw, not base64)

image image

better to just lazy load it from CDN instead of bundling it into the source

the bundle.js is currently sitting at 5.27MB, already quite big, I don't think we can spend more than 100KB for such a small feature

@allozaur
Copy link
Copy Markdown
Contributor

allozaur commented Jun 5, 2026

I will take a look at this after the weekend

@NickM-27 NickM-27 force-pushed the heic-image-support branch from 7f19f8e to 3d21058 Compare June 5, 2026 12:42
@NickM-27
Copy link
Copy Markdown
Author

NickM-27 commented Jun 5, 2026

I will take a look at this after the weekend

Sounds good, I just pushed a commit with pulling the lib from a CDN instead, but happy to make any changes y'all want after you take a look

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Support for HEIF/HEIC image input format

3 participants