Skip to content

Instantly share code, notes, and snippets.

@hasansezertasan
Created November 2, 2025 23:52
Show Gist options
  • Select an option

  • Save hasansezertasan/cba2a1270f1f8ec4066d4674a7520dde to your computer and use it in GitHub Desktop.

Select an option

Save hasansezertasan/cba2a1270f1f8ec4066d4674a7520dde to your computer and use it in GitHub Desktop.
Convert PNG to ICO format. Also, did you know that ICO format can have multiple size of image in itself, I didn't...
# /// script
# requires-python = ">=3.12"
# dependencies = ["pillow"]
# ///
from PIL import Image
def main() -> None:
with Image.open("icon.png") as img:
img.save(
"icon.ico",
format="ICO",
sizes=[
(16, 16),
(24, 24),
(32, 32),
(48, 48),
(64, 64),
(128, 128),
(256, 256),
],
)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment