You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
.ico coder needs magic number detection (coders/icon.c) #4230
Is your feature request related to a problem? Please describe.
The ICO coder lacks magic number detection. You can see this behavior on the command line. These two files are identical:
$ identify favicon.bogus favicon.ico
favicon.ico[0] ICO 48x48 48x48+0+0 8-bit sRGB 0.000u 0:00.001
identify: no decode delegate for this image format `BOGUS' @ error/constitute.c/ReadImage/575.
The real problem is when favicons are loaded from the network using the various API bindings. For example, with the go bindings you have to save the .ICO to a temp file and load it that way. Similar shenanigans are required for the ruby bindings.
Describe the solution you'd like
Add magic number to the coder. I think the two magic numbers are 00 00 01 00 (ICO) and 00 00 02 00 (CUR).
Thanks for all your hard work on ImageMagick, we use it regularly!
The format does not include a magic # field (see https://en.wikipedia.org/wiki/ICO_(file_format)), therefore, we cannot automatically detect the format other than relying on the .ico file extension.
I think maybe there is a magic number, for two reasons:
I am parsing the favicons of the top 1,000 alexa (tranco) sites. They all use 00 00 01 00 as the magic number. I haven't found any that don't contain that magic number.
The first two bytes are reserved-- meaning they are unreliable as they may change. Your link is also telling-- they discuss identification and they say "Note that this byte sequence is not very discriminating." For ImageMagick, we cannot rely on these bytes to identify ICO images s it will likely generate too many false positives. However, you could add the detection to your workflow and add the explicit icon:image.whatever to the ImageMagick command line.
Activity
urban-warrior commentedon Sep 18, 2021
Try this command:
The format does not include a magic # field (see https://en.wikipedia.org/wiki/ICO_(file_format)), therefore, we cannot automatically detect the format other than relying on the .ico file extension.
gurgeous commentedon Sep 18, 2021
I think maybe there is a magic number, for two reasons:
00 00 01 00as the magic number. I haven't found any that don't contain that magic number.Could we be mistaken?
urban-warrior commentedon Sep 18, 2021
The first two bytes are reserved-- meaning they are unreliable as they may change. Your link is also telling-- they discuss identification and they say "Note that this byte sequence is not very discriminating." For ImageMagick, we cannot rely on these bytes to identify ICO images s it will likely generate too many false positives. However, you could add the detection to your workflow and add the explicit
icon:image.whateverto the ImageMagick command line.