Skip to content

Detect image/vnd.microsoft.icon mime types as ImageFormat::Ico#2434

Merged
fintelia merged 1 commit intoimage-rs:mainfrom
MYDIH:main
Mar 7, 2025
Merged

Detect image/vnd.microsoft.icon mime types as ImageFormat::Ico#2434
fintelia merged 1 commit intoimage-rs:mainfrom
MYDIH:main

Conversation

@MYDIH
Copy link
Copy Markdown
Contributor

@MYDIH MYDIH commented Mar 6, 2025

I just added 'image/vnd.microsoft.icon' as mime for the ImageFormat::Ico format. I think it's a valid mime for this image type (iana)

Returning 'icon/x-icon' seems valid during the opposite operation (retrieving a mime from the ImageFormat), no change needed here IMO

Context:

I'm using egui_extra to load a bunch of favicons in a UI, there is a loader that forwards image loading to this crate, using the ImageFormat to detect which format to use. Some favicons weren't loading since the mime was 'image/vnd.microsoft.icon'. For the full chain to work properly, a change is also needed in egui_extra though (PR)

@fintelia fintelia merged commit c62d3ac into image-rs:main Mar 7, 2025
30 of 32 checks passed
lucasmerlin pushed a commit to emilk/egui that referenced this pull request Mar 20, 2025
…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
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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants