I am building a Python application bundled with PyInstaller which is available for Windows, Linux (as AppImage) and MacOS.
I need shortcut icons for those. I have a logo, but I am struggling to bring it to the right format. It seems to me that all three platforms use different icon sizes and formats.
Is there any online/offline generator that allows me to create icons for all three platforms from a jpg file?
As you have mentioned you only need to convert the logo from jpg to icon files for the respective OS, then try image converter of Pillow. This code will generate icon files for all (Mac, Win, Linux)
from PIL import Image
filename = r'logo.jpg' # the directory of logo file
img = Image.open(filename) # reads the JPG file
# Generate and save the logo files
img.save('Win_logo.ico') # On windows, icon file extension is .ico
img.save('Mac_logo.icns') # On Mac OS, icon file extension is .icns
# Note: Creating icns requires Mac OS
img.save('Linux_logo.png') # in case if your AppImage requires any logo file
Optionally, you may specify the icon sizes (for Windows) you want:
icon_sizes = [(16,16), (32, 32), (48, 48), (64,64)]
img.save('logo.ico', sizes=icon_sizes)
The Pillow docs say that by default it will generate sizes
[(16, 16), (24, 24), (32, 32), (48, 48), (64, 64), (128, 128), (255, 255)]
and any size bigger than the original size or 255 will be ignored.
check the Pillow docs for more info.
as the Pyinstaller is OS based and ICNS is also generated OS based
from platform import system as OS_Name
os_name = OS_Name()
filename = r'logo.jpg' # the directory of logo file
img = Image.open(filename) # reads the JPG file
# Generate and save the logo files
if os_name == 'Windows': img.save('Win_logo.ico') # On windows, icon file extension is .ico
if os_name == 'Darwin' : img.save('Mac_logo.icns') # On Mac OS, icon file extension is .icns
# on Linux the os_name is 'Linux'
img.save('Linux_logo.png') # in case if your AppImage requires any logo file
The best os independent way is the Online way. Cloud Convert is a great tool for that. However, you must convert your jpg
to png
first. [Note: Always try to use png
for logos as they have transparency and more convient]
You may use the Above code's PNG part to auto-convert your JPG to PNG, or use JPG to PNG
Finally convert your PNG file using PNG to ICNS.