Page 1 of 1

Creating a Windows icon file for "Devices and Printers"

Posted: 2016-08-03T10:53:00-07:00
by AzJazz
Hi - I am trying to create a Windows 7 - compatible .ICO file that will be used in the "Devices and Printers" window. I am using the Windows Metadata Authoring Wizard (https://msdn.microsoft.com/en-us/librar ... s.85).aspx) that requires the ICO file to have multiple resolutions and bit depths.

The following icon resolutions and depths are required in the ICO file:
  • 256x256 32bit + Alpha
  • 48x48: 32bit + Alpha
  • 48x48: 8bit 256
  • 48x48: 4bit 16
  • 32x32: 32bit + Alpha
  • 32x32: 8bit 256
  • 32x32: 4bit 16
  • 24x24: 32bit + Alpha
  • 24x24: 8bit 256
  • 24x24: 4bit 16
  • 16x16: 32bit + Alpha
  • 16x16: 8bit 256
  • 16x16: 4bit 16
I tried to create an ICO using ImageMagick from my source PNG file, but I couldn't figure out the proper -clone and -colors options. It seemed like -colors could not be used in the -clone section.

I don't know if this is even the right route, but this is what I tried:

Code: Select all

convert image.png  ( -clone 0 -resize 256x256 ) ( -clone 0 -resize 48x48 ) ( -clone 0 -resize 48x48 -colors 256) ( -clone 0 -resize 48x48 -colors 16) ( -clone 0 -resize 32x32 ) ( -clone 0 -resize 32x32 -colors 256) ( -clone 0 -resize 32x32 -colors 16) ( -clone 0 -resize 24x24 ) ( -clone 0 -resize 24x24 -colors 256) ( -clone 0 -resize 24x24 -colors 16) ( -clone 0 -resize 16x16 ) ( -clone 0 -resize 16x16 -colors 256) ( -clone 0 -resize 16x16 -colors 16) -delete 0 -alpha remove favicon.ico
This resulted in the following error:

convert: unbalanced parenthesis `favicon.ico' @ error/convert.c/ConvertImageCommand/3248

Can anyone help with the Windows command line that would get me all the icon resolutions and bit depths listed above?

Thanks,

AzJazz

Re: Creating a Windows icon file for "Devices and Printers"

Posted: 2016-08-03T11:02:02-07:00
by snibgo
Every parenthesis needs a space before and after it.

Re: Creating a Windows icon file for "Devices and Printers"

Posted: 2016-08-03T12:12:51-07:00
by AzJazz
snibgo wrote:Every parenthesis needs a space before and after it.
Ah, thanks, snibgo!

That fixed the parenthesis error that I was seeing. Unfortunately, the command line apparently isn't generating the image formats that I need: Image

I was just experimenting on the command line values, based on what I found in these forums and the web. I guess the experiment "failed". :D

Also, the ICO file I generated didn't contain a 256x256 image, which I thought my first clone would generate. That wasn't working, even though there wasn't an error message for that.

Can anyone suggest what I should have for the command line to generate the required images and resolutions?

Thanks,

AzJazz

Re: Creating a Windows icon file for "Devices and Printers"

Posted: 2016-08-03T12:21:45-07:00
by AzJazz
Update:

Some stuff is working. I fixed the transparency errors, and I do see a 256x256 image now.

I now have these errors:

Image

I think that the -colors switch is not changing the bit depth the way that I expected.

Re: Creating a Windows icon file for "Devices and Printers"

Posted: 2016-08-03T12:36:48-07:00
by GeeMack
AzJazz wrote:I think that the -colors switch is not changing the bit depth the way that I expected.
Maybe try something ike this to set the bit depths on the layers...

Code: Select all

convert input.png -write mpr:iconimg +delete ^
   ( mpr:iconimg -resize 256x256 ) ^
   ( mpr:iconimg -resize 48x48 ) ^
   ( mpr:iconimg -resize 48x48 -depth 8 -colors 256 ) ^
   ( mpr:iconimg -resize 48x48 -depth 4 -colors 16 ) ^
   ( mpr:iconimg -resize 32x32 ) ^
   ( mpr:iconimg -resize 32x32 -depth 8 -colors 256 ) ^
   ( mpr:iconimg -resize 32x32 -depth 4 -colors 16 ) ^
   ( mpr:iconimg -resize 24x24 ) ^
   ( mpr:iconimg -resize 24x24 -depth 8 -colors 256 ) ^
   ( mpr:iconimg -resize 24x24 -depth 4 -colors 16 ) ^
   ( mpr:iconimg -resize 16x16 ) ^
   ( mpr:iconimg -resize 16x16 -depth 8 -colors 256 ) ^
   ( mpr:iconimg -resize 16x16 -depth 4 -colors 16 ) ^
      output.ico

Re: Creating a Windows icon file for "Devices and Printers"

Posted: 2016-08-03T12:51:53-07:00
by snibgo
Is the input.png image exactly square? If it isn't, crop it to make it square before GeeMack's command.

Re: Creating a Windows icon file for "Devices and Printers"

Posted: 2016-08-03T13:32:30-07:00
by AzJazz
GeeMack wrote: Maybe try something ike this to set the bit depths on the layers...

Code: Select all

convert input.png -write mpr:iconimg +delete ^
   ( mpr:iconimg -resize 256x256 ) ^
   ( mpr:iconimg -resize 48x48 ) ^
   ( mpr:iconimg -resize 48x48 -depth 8 -colors 256 ) ^
   ( mpr:iconimg -resize 48x48 -depth 4 -colors 16 ) ^
   ( mpr:iconimg -resize 32x32 ) ^
   ( mpr:iconimg -resize 32x32 -depth 8 -colors 256 ) ^
   ( mpr:iconimg -resize 32x32 -depth 4 -colors 16 ) ^
   ( mpr:iconimg -resize 24x24 ) ^
   ( mpr:iconimg -resize 24x24 -depth 8 -colors 256 ) ^
   ( mpr:iconimg -resize 24x24 -depth 4 -colors 16 ) ^
   ( mpr:iconimg -resize 16x16 ) ^
   ( mpr:iconimg -resize 16x16 -depth 8 -colors 256 ) ^
   ( mpr:iconimg -resize 16x16 -depth 4 -colors 16 ) ^
      output.ico
Thanks, Geemack & snibgo! That worked!

The new device image now appears in my "Devices and Printers" window.

Cheers,

AzJazz