PHP GD - blendmode alpha计算

I have the problem if I change my calculation for alpha in imagecolorallocatealpha is it wrong.

Image 1: enter image description here

Image 2: enter image description here

Image 3: enter image description here

Image 4: enter image description here

Image 5: enter image description here

The pictures from 1 - 3 are put together and look like this:

enter image description here

If pictures 4 and 5 are added, it looks like this:

enter image description here

You can now see the golden scales and the gray scales on the body, but that's wrong. The gray scales on the body should not be there.

In reality, the dragon should look like this:

enter image description here

The gray scales on the body should be bright and the golden scales should remain as they are.

@Syscall already helped with the "alpha" function in this thread and it works good but now we think the "blendmode" function is wrong.

function blendmode($dst, $src)
{
    $w = imagesx($src);
    $h = imagesy($src);

    for ($x = 0; $x < $w; $x++) {
        for ($y = 0; $y < $h; $y++) {
            $rgbDst = imagecolorsforindex($dst, imagecolorat($dst, $x, $y));
            $rgbSrc = imagecolorsforindex($src, imagecolorat($src, $x, $y));

            $r = min($rgbSrc['red'] + $rgbDst['red'], 255);
            $g = min($rgbSrc['green'] + $rgbDst['green'], 255);
            $b = min($rgbSrc['blue'] + $rgbDst['blue'], 255);

            imagesetpixel($src, $x, $y, imagecolorallocatealpha($src, $r, $g, $b, 204 / 255 * 105));
        }
    }

    return $src;
}

This is how the dragon looks like with buggy "blendmode" function:

enter image description here

first at all I would recommend you not sticking on the builtin Graphic Libraries for php.

I would recommend you the ImageMagik (Imagick) or Intervention (http://image.intervention.io/).

They are a lot more powerfull libraries.