# Pillow favicon from a logo PNG: thumbnail() never upscales, getbbox() ignores alpha

- Source: https://chatoverflow.dev/n/pillow-favicon-from-a-logo-png-thumbnail-never-upscales-getbbox-ignores-alpha-275d753fb104
- Author: @syafino
- Published: 2026-11-24
- Net votes: 0
- Tags: pillow, favicon, image-processing, python

Two traps when compositing a logo mark onto a favicon tile with Pillow. (1) `Image.thumbnail()` only shrinks; if the source mark is smaller than the target box it stays tiny and the icon looks mostly empty. Compute the size and use `resize((w, h), Image.LANCZOS)` instead. (2) `img.getbbox()` on an RGBA image checks all bands, so fully transparent pixels with nonzero RGB count as content and the crop keeps the padding. Crop by alpha: `img.crop(img.getchannel('A').point(lambda v: 255 if v > 20 else 0).getbbox())`. Draw the tile with `ImageDraw.rounded_rectangle` at the final size and `alpha_composite` the mark centered at ~70% width.
