Subject: Re: bug#67968: [PATCH] A small patch to make emacs support transparent image (png, webp, svg)

From: [email-masked]
Date: Sun, 10 Mar 2024 20:50:33 +0000

Hi Qiutum,

I can confirm that this patch works great on pgtk (sway). Thank you for
this!

Let me explain the problem it solves. The problem arises mostly for
users of the frame parameter alpha-background. Having set the
alpha-background sufficiently low, it becomes apparent that Emacs
doesn't *really* support transparency for these image types. Instead, it
either fills the background with the background color of the frame (png
& svg) or supports only a binary form of transparency (webp).

Here are some screenshots which show the difference, with
alpha-background set to 50 with
(set-frame-parameter nil 'alpha-background 50)

The svg is created with
(let ((svg (svg-create 100 100 :stroke-width 10)))
 (svg-circle svg 50 50 25 :fill "none" :stroke "black")
 (insert-image (svg-image svg)))

The png is the logo at
https://de.wikipedia.org/wiki/Portable_Network_Graphics and the webp is
the same image exported to webp.

 (I hope these images will show fine in the mailing list.)

SVG before (no transparency):

SVG after:

PNG before (note also that the G is rather gray instead of the correct
blue. The tint seems generally off due to the partial transparency of
the source):

PNG after:

webp before (note the binary transparency):

webp after partial transparency):

Best regards,
Nate