I was trying to batch convert my logo into multiple sizes for my python based app packaged with fbs and ended up using the below to do this based on the above answers.
worked perfectly even the .ico one generated and shows in Windows. In Linux it shows the one Icon.ico as compressed, but not too worried about that as its only going to be used in Windows.
from PIL import Image
icon_sizes = [(16, 16), (24, 24), (32, 32), (48, 48), (64, 64), (128, 128), (255, 255)]
image = Image.open('/some/path/to/logo-python/logo.png')
fileoutpath = '/some/path/to/logo-python/'
for size in icon_sizes:
print(size[0])
fileoutname = fileoutpath + str(size[0]) + ".png"
new_image = image.resize(size)
new_image.save(fileoutname)
new_logo_ico_filename = fileoutpath + "Icon.ico"
new_logo_ico = image.resize((128, 128))
new_logo_ico.save(new_logo_ico_filename, format="ICO",quality=90)