Skip to content

Saving .ico saves more sizes than necessary #2266

Description

@hugovk

What did you do?

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

print im.info['sizes']
print im_saved.info['sizes']

assert im_saved.info['sizes'] == set([(16, 16), (24, 24), (32, 32), (48, 48)])

What did you expect to happen?

No assertion, and only relevant sizes saved:

set([(16, 16), (48, 48), (32, 32)])
set([(16, 16), (24, 24), (48, 48), (32, 32)])
$ identify python.ico
python.ico[0] ICO 16x16 16x16+0+0 32-bit sRGB 15.1KB 0.000u 0:00.002
python.ico[1] ICO 32x32 32x32+0+0 32-bit sRGB 15.1KB 0.000u 0:00.008
python.ico[2] ICO 48x48 48x48+0+0 32-bit sRGB 15.1KB 0.000u 0:00.013
$ identify saved.ico
saved.ico[0] PNG 16x16 16x16+0+0 8-bit sRGB 12.7KB 0.000u 0:00.003
saved.ico[1] PNG 24x24 24x24+0+0 8-bit sRGB 12.7KB 0.000u 0:00.006
saved.ico[2] PNG 32x32 32x32+0+0 8-bit sRGB 12.7KB 0.000u 0:00.007
saved.ico[3] PNG 48x48 48x48+0+0 8-bit sRGB 12.7KB 0.000u 0:00.010

What actually happened?

set([(16, 16), (48, 48), (32, 32)])
set([(64, 64), (16, 16), (256, 256), (24, 24), (32, 32), (128, 128), (48, 48)])
Traceback (most recent call last):
  File "test.py", line 9, in <module>
    assert im_saved.info['sizes'] == set([(16, 16), (24, 24), (32, 32), (48, 48)])
AssertionError
$ identify python.ico
python.ico[0] ICO 16x16 16x16+0+0 32-bit sRGB 15.1KB 0.000u 0:00.002
python.ico[1] ICO 32x32 32x32+0+0 32-bit sRGB 15.1KB 0.000u 0:00.008
python.ico[2] ICO 48x48 48x48+0+0 32-bit sRGB 15.1KB 0.000u 0:00.013
$ identify saved.ico
saved.ico[0] PNG 16x16 16x16+0+0 8-bit sRGB 12.7KB 0.000u 0:00.003
saved.ico[1] PNG 24x24 24x24+0+0 8-bit sRGB 12.7KB 0.000u 0:00.006
saved.ico[2] PNG 32x32 32x32+0+0 8-bit sRGB 12.7KB 0.000u 0:00.007
saved.ico[3] PNG 48x48 48x48+0+0 8-bit sRGB 12.7KB 0.000u 0:00.010
saved.ico[4] PNG 48x48 48x48+0+0 8-bit sRGB 12.7KB 0.000u 0:00.011
saved.ico[5] PNG 48x48 48x48+0+0 8-bit sRGB 12.7KB 0.000u 0:00.013
saved.ico[6] PNG 48x48 48x48+0+0 8-bit sRGB 12.7KB 0.000u 0:00.016

What versions of Pillow and Python are you using?

Python 2.7.11
Pillow 3.4.2

Metadata

Metadata

Assignees

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