Skip to content

egui_extras: Allow loading multi-mime formats using the image_loader#5769

Merged
lucasmerlin merged 1 commit intoemilk:masterfrom
MYDIH:master
Mar 20, 2025
Merged

egui_extras: Allow loading multi-mime formats using the image_loader#5769
lucasmerlin merged 1 commit intoemilk:masterfrom
MYDIH:master

Conversation

@MYDIH
Copy link
Copy Markdown
Contributor

@MYDIH MYDIH commented Mar 6, 2025

Hi !

I'm using egui and egui_extra to build a demo tool for a crate I'm building. In this crate I load favicons from a lot of websites, and I have some failures on some .ico files. After tracking this thing down, I guess there is two issues (kinda), in the image crate, 'image/vnd.microsoft.icon' isn't recognized as the valid mime for an ico image (I created a PR), and the code to detect if a given mime type is compatible with the image crate decoders in this crate do not support multi-mime type formats.

ImageFormat::to_mime_type is only returning one mime for a given format (which is fine), we compare the result of this method to guess if the format is valid/enabled. Retriveing the correct format using ImageFormat::from_mime_type would allow more mime to be considered valid since multiple mime can match the same format.

The same applies to the extension detection, which I also modified to stay consistent

Thanks

Copy link
Copy Markdown
Collaborator

@lucasmerlin lucasmerlin left a comment

Choose a reason for hiding this comment

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

Nice, thank you!

@github-actions
Copy link
Copy Markdown

Preview available at https://egui-pr-preview.github.io/pr/5769-master
Note that it might take a couple seconds for the update to show up after the preview_build workflow has completed.

@lucasmerlin lucasmerlin merged commit 1545dec into emilk:master Mar 20, 2025
14 of 27 checks passed
@emilk emilk changed the title [egui_extra] Allow loading multi-mime formats using the image_loader egui_extras: Allow loading multi-mime formats using the image_loader Jul 9, 2025
darkwater pushed a commit to darkwater/egui that referenced this pull request Aug 24, 2025
…milk#5769)

Hi ! 

I'm using egui and egui_extra to build a demo tool for a crate I'm
building. In this crate I load favicons from a lot of websites, and I
have some failures on some .ico files. After tracking this thing down, I
guess there is two issues (kinda), in the image crate,
'image/vnd.microsoft.icon' isn't recognized as the valid mime for an ico
image (I created a [PR](image-rs/image#2434)),
and the code to detect if a given mime type is compatible with the image
crate decoders in this crate do not support multi-mime type formats.


[ImageFormat::to_mime_type](https://github.com/image-rs/image/blob/85f2412d552ddd2f576e16d023fd352589f4c605/src/image.rs#L216C12-L216C24)
is only returning one mime for a given format (which is fine), we
compare the result of this method to guess if the format is
valid/enabled. Retriveing the correct format using
[ImageFormat::from_mime_type](https://github.com/image-rs/image/blob/85f2412d552ddd2f576e16d023fd352589f4c605/src/image.rs#L166)
would allow more mime to be considered valid since multiple mime can
match the same format.

The same applies to the extension detection, which I also modified to
stay consistent

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

Labels

egui_extras feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants