views:

1799

answers:

2

Hello,

I've been trying to embed an icon (.ico) into my "compyled" .exe with py2exe.

Py2Exe does have a way to embed an icon:

windows=[{
    'script':'MyScript.py',
    'icon_resources':[(1,'MyIcon.ico')]
}]

And that's what I am using. The icon shows up fine on Windows XP or lower, but doesn't show at all on Vista. I suppose this is because of the new Vista icon format, which can be in PNG format, up to 256x256 pixels.

So, how can I get py2exe to embed them into my executable, without breaking the icons on Windows XP?

I'm cool with doing it with an external utility rather than py2exe - I've tried this command-line utility to embed it, but it always corrupts my exe and truncates its size for some reason.

+9  A: 

Vista uses icons of high resolution 256x256 pixels images, they are stored using PNG-based compression. The problem is if you simply make the icon and save it in standard XP ICO format, the resulting file will be 400Kb on disk. The solution is to compress the images. The compression scheme used is PNG (Portable Network Graphic) because it has a good lossless ratio and supports alpha channel.

And use

png2ico myicon.ico logo16x16.png logo32x32.png logo255x255.png

It creates an ICO file from 1 or more PNG's and handles multiple sizes etc. And I guess XP would have no problem with that.

simplyharsh
The icon created by png2ico does work, but png2ico refuses to use the 256x256 PNG version of my icon, it only takes smaller sizes. (It says: "Width must be multiple of 8 and <256. Height must be <256.") Is there any way to go around this limitation?
WindPower
Perhaps make your max resolution 255x255? I imagine it won't look much different..
John Fouhy
A: 

i have the same problem, but png2ico refuses to use the 248x248 PNG version of my icon. 248 / 8 = 31, and 248 < 256. Why it dosen't work?

ant