Alpha channel overwrites underlying non transparent part after imagecopyresampled

  gd, php, php-8, php-gd

Got a strange thing in production env. Alpha channel overwrites underlying non transparent part after imagecopyresampled.

In dev it works as expected: Text

But in prod im getting this: Text

    $bubble = imagecreatefrompng($bubblePath);
    imagealphablending($bubble, true);
    imagesavealpha($bubble, true);

    $icon = imagecreatefrompng($iconPath)
    imagealphablending($icon, true);
    imagesavealpha($icon, true);

    imagecopyresampled($bubble, $icon, ($bubbleWidth - $newIconWidth) / 2, 200 - $newIconHeight / 2, 0, 0, $newIconWidth, $newIconHeight, $iconWidth, $iconHeight);


    imagepng($bubble, "./result.png");

My app uses docker, so environments are built and should be pretty same. PHP 8.0.10

Source: Ask PHP

LEAVE A COMMENT