mirror of
https://github.com/gauvainboiche/ketapk.git
synced 2026-09-02 03:03:11 +02:00
32 lines
918 B
Python
32 lines
918 B
Python
# Source - https://stackoverflow.com/a/36168447
|
|
# Posted by Ronan Paixão
|
|
# Retrieved 2026-08-31, License - CC BY-SA 3.0
|
|
|
|
from PIL import Image
|
|
|
|
ICONS_DIR = 'graphism/icons'
|
|
|
|
icon_32 = Image.open(f'{ICONS_DIR}/32x32.png')
|
|
icon_128 = Image.open(f'{ICONS_DIR}/128x128.png')
|
|
icon_256 = Image.open(f'{ICONS_DIR}/128x128@2x.png')
|
|
|
|
# Use each source PNG at its native resolution instead of resampling
|
|
# a single base image, so small sizes stay sharp.
|
|
icon_256.save(
|
|
f'{ICONS_DIR}/icon.ico',
|
|
sizes=[(32, 32), (128, 128), (256, 256)],
|
|
append_images=[icon_32, icon_128],
|
|
)
|
|
|
|
# Source - https://pypi.org/project/icnsutil/
|
|
|
|
import icnsutil
|
|
|
|
icns = icnsutil.IcnsFile()
|
|
icns.add_media(file=f'{ICONS_DIR}/32x32.png')
|
|
icns.add_media(file=f'{ICONS_DIR}/128x128.png')
|
|
icns.add_media(file=f'{ICONS_DIR}/128x128@2x.png')
|
|
icns.write(f'{ICONS_DIR}/icon.icns')
|
|
|
|
print(f'Generated {ICONS_DIR}/icon.ico and {ICONS_DIR}/icon.icns')
|