Skip to content

.ico files are saved as 255x255 #2264

Description

@klvbdmh

What did you do?

Loading an .ico of the size 256x256 and then saving it results in an .ico file of the size 255x255. I tested it on an example .ico file: http://www.axialis.com/tutorials/iw/down.ico

What did you expect to happen?

The icon file should stay the same after saving. No other adjustments have been made. See the code below.

What actually happened?

The saved .ico file ended up as 255x255 file. Because Windows doesn't support 255x255 size for .ico files, it is downscaled to 128x128 when used as desktop icons. Example. The Chromium and Chrome icons are default ones, the Chrome Canary one was saved with Pillow.

What versions of Pillow and Python are you using?

Pillow 3.4.2, Python 3.5.2

from PIL import Image
im = Image.open('down.ico')
im.save('saved.ico')
im_saved = Image.open('saved.ico')

In [2]: im.size
Out[2]: (256, 256)

In [3]: im_saved.size
Out[3]: (255, 255)

(255, 255) appears on the list of sizes at https://github.com/python-pillow/Pillow/blob/master/PIL/IcoImagePlugin.py#L45 .

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions