Conversion from png to ico fails

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
peterhull90
Posts: 5
Joined: 2012-01-13T08:50:08-07:00
Authentication code: 8675308

Conversion from png to ico fails

Post by peterhull90 »

Using ImageMagick 6.7.3-10 on Windows XP
With this command

Code: Select all

convert image.png image.ico
a file image.ico is produced but does not appear to be a valid Windows icon (Explorer just shows the default icon)
I have a batch file which I wrote some time ago and which used to work perfectly when I had IM 6.5.8 installed. Has anything changed in the icon writing code since then?
Converting bmp to ico and gif to ico still seem to work perfectly.

Pete
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: Conversion from png to ico fails

Post by glennrp »

Please try

Code: Select all

convert image.png -strip image.ico
It may be that we are writing some ancillary chunks that we did not write in older versions. If this fixes the situation, I'll see about omitting those ancillary chunks, as the -strip option does, when writing an ICO.

It also may be that we are writing an indexed PNG while previously we were writing a Truecolor PNG. If the -strip option doesn't help, please try

Code: Select all

convert image.png -define png:color-type=6 image.ico
(or color-type=2 if you know it is opaque)
User avatar
coche
Posts: 1
Joined: 2012-01-14T23:46:59-07:00
Authentication code: 6789
Location: San Salvador, El Salvador

Re: Conversion from png to ico fails

Post by coche »

Thanks glennrp!
The following code worked for me:

Code: Select all

convert image.png -define png:color-type=6 image.ico
Before using your command, I used the simple: "convert image.png image.ico" and although the ico file was created well, I noticed that the "dimensions" meta data was not written in the file (according to the file properties in Windows 7 64 bit).

After using your command I got the dimensions meta data written properly in the file.
peterhull90
Posts: 5
Joined: 2012-01-13T08:50:08-07:00
Authentication code: 8675308

Re: Conversion from png to ico fails

Post by peterhull90 »

Thanks for the swift reply.

Neither of those solutions worked for me, unfortunately. I had a more detailed look at the generated icon. IM is creating the icons with PNG format images, which is fine for Vista and later but not compatible with XP and earlier (which I have). I assume that earlier versions used BITMAP format images, which was why it was OK.

For now a work around is to go via GIF (or maybe '32-bit' BMPs) or use an earlier version of IM.

Is there any way of providing a flag to create 'old-style' icons or is it too late for XP now?

Pete
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: Conversion from png to ico fails

Post by glennrp »

peterhull90 wrote: Is there any way of providing a flag to create 'old-style' icons or is it too late for XP now?
Try

Code: Select all

 convert image.png -compress none image.ico
peterhull90
Posts: 5
Joined: 2012-01-13T08:50:08-07:00
Authentication code: 8675308

Re: Conversion from png to ico fails

Post by peterhull90 »

You've thought of everything, sir!

That works fine, thanks very much.

Pete
Post Reply