0

I'm using PIL to convert images to icons

    From PIL import Image
    img = Image.open(logo.png)
    img.save('logo.ico')

it works by creating the logo.ico file, but then it always shows the first image i converted from, if i change the logo.png to another image, it doesn't change the logo.ico from the first image..

also when i convert to .ico the image gets streched weirdly even when i specify the dimentions

those two problems don't happen if i'm converting to other image formats, like from png to jpg for example.

Edit: managed to solve the first problem by creating new.ico files every time using random names for each new one.

humantrash
  • 63
  • 6
  • Pillow will force square sized images when saving to [ICO](https://pillow.readthedocs.io/en/stable/handbook/image-file-formats.html#ico). I guess, your input images are not square sized, such that the stretching. You'd need to [add proper (transparent?) borders](https://stackoverflow.com/q/11142851/11089932) to keep the aspect ratio of your images. If that doesn't help you, please provide a [mre] including proper Python code and input images. – HansHirse Sep 02 '21 at 09:22
  • @HansHirse ty for the help, it worked :), i made a new transparent square image with each side having the higher value of the original image parameters(height,width) then i pasted the original image on top of the transparent image and now when i make an icon using PIL it appears as if it has the same aspect ratio of the original image lol. – humantrash Sep 02 '21 at 12:20

0 Answers0