I'm converting images to icons using this code:
import PIL.image
img = PIL.Image.open ("imagepath.png")
img.save ("iconpath.ico")
This is giving me an icon file as desired, but when I try to open it an error pops up:
Paint:

Microsoft photos error:

When I try to open other icons with the same programs they work perfectly, but it doesn't with the ones I made. Does anyone know any other way or library for doing this?