All Articles Kinsa Creative

Generate Web Icons in Python with PIL

Referencing this article regarding formats and sizes.

Requires PIL. Create a virtual env in a working directory and install:

python -m venv .venv
source .venv/bin/activate
pip install pillow

In Sketch, or other vector editing application, from a 512px square artboard, export a SVG as icon.svg

Export again as a 512px square PNG, naming the file icon-512.png

Noting where those files are saved, in a Python shell, run:

from PIL import Image
logo ='/path/to/icon-512.png')

Move all the images to the root of the website.

Create a new file at the root of the website named manifest.webmanifest with the content:

  "icons": [
    { "src": "/icon-192.png", "type": "image/png", "sizes": "192x192" },
    { "src": "/icon-512.png", "type": "image/png", "sizes": "512x512" }

Load the images, in the head of the document add:


Email us at