Skip to content

An invalid ICO image is generated when it includes multiple BMP images #2192

Description

@sorairolake

Discussed in #2185

Originally posted by sorairolake March 26, 2024
I wrote a code to create a ICO file containing multiple BMP or PNG images:

https://github.com/sorairolake/favico/blob/1c5cb360350097900988bb407c81368d55512648/src/generate.rs#L40-L59

The generated ICO file containing multiple PNG images seems correct, but it containing multiple BMP images seems corrupted:

$ identify png/favicon.ico
png/favicon.ico[0] PNG 16x16 16x16+0+0 8-bit sRGB 269B 0.010u 0:00.000
png/favicon.ico[1] PNG 32x32 32x32+0+0 8-bit sRGB 323B 0.010u 0:00.000
png/favicon.ico[2] PNG 48x48 48x48+0+0 8-bit sRGB 1027B 0.000u 0:00.000

$ identify bmp/favicon.ico
identify: improper image header `bmp/favicon.ico' @ error/icon.c/ReadICONImage/400.

How can I create a ICO file containing multiple BMP images which is not corrupted?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions