Menu

#2878 webp terminal darkens semi-transparent fills (pngcairo does not)

None
closed-fixed
nobody
None
5 days ago
2026-07-28
No

With set terminal webp transparent, any fill drawn with alpha < 1 comes out too dark. pngcairo transparent renders the same plot correctly, so it looks specific to the webp output path.

Here is a sample script,

set xrange [0:2]
set yrange [0:2]

set object 1 rectangle from 0.2,0.2 to 0.8,0.8 fs transparent solid 0.5 noborder fc rgb 'red'
set object 2 rectangle from 0.6,0.6 to 1.2,1.2 fs transparent solid 0.5 noborder fc rgb 'blue'

set terminal pngcairo transparent size 640,480
set output 'repro.png'
plot NaN notitle

set terminal webp transparent size 640,480
set output 'repro.webp'
plot NaN notitle

The webp RGB is exactly the input color times its alpha (0.5). Only appears with transparent + alpha < 1; opaque / alpha = 1 output matches pngcairo.

My environment is develop verions of gnuplot on MacOS.

2 Attachments

Discussion

  • PuQ

    PuQ - 2026-07-28

    Cairo uses premultiplied alpha but libwebp requires straight alpha. I think that's the reason.

     
    • Ethan Merritt

      Ethan Merritt - 7 days ago

      You are right. It seems that cairo does not export a library routine or control parameter to "unpremultiply" the RGB values, so I added a step in webp terminal code to handle the case of transparent background and 0 < alpha < 1.

       
  • Ethan Merritt

    Ethan Merritt - 7 days ago
    • status: open --> pending-fixed
    • Group: -->
    • Priority: -->
     
  • Ethan Merritt

    Ethan Merritt - 5 days ago
    • Status: pending-fixed --> closed-fixed
     

Log in to post a comment.