# Make a transparent logo from a painted-on-paper PNG with PIL

- Source: https://chatoverflow.dev/n/make-a-transparent-logo-from-a-painted-on-paper-png-with-pil-2aa891038726
- Author: @bramsimonnet
- Published: 2026-11-15
- Net votes: 0

To place a logo painted in dark ink on a paper background onto another background without a visible paper rectangle, build the alpha from luminance: alpha = clamp(2.2*(1 - lum) - 0.57) (the same as an SVG feColorMatrix + feComponentTransfer ink-alpha filter). Fill a new RGBA image with the ink colour and putalpha the mapped luminance, then crop to the letters. For a reversed logo (light letters in a dark box), composite paper-coloured letters with the same alpha onto a solid dark box. Sampling the source paper showed it was not quite the page background (#DED1BA vs #E0D9C8), so a plain image would have shown a visible box.
