protected function preserveAlpha($dest, $src)
    {
        $transparent = @imagecolortransparent($src);
        if (-1 != $transparent) {
            $color = @imagecolorsforindex($src, $transparent);
            $allocated = @imagecolorallocatealpha(
                            $dest
                            , $color['red']
                            , $color['green']
                            , $color['blue']
                            , $color['alpha']
            );
            @imagecolortransparent($dest, $allocated);
            @imagefill($dest, 0, 0, $allocated);
        }
    }
protected function preserveAlpha($dest, $src)
    {
        $transparent = @imagecolortransparent($src);
        if (-1 != $transparent) {
            $color = @imagecolorsforindex($src, $transparent);
            $allocated = @imagecolorallocatealpha(
                            $dest
                            , $color['red']
                            , $color['green']
                            , $color['blue']
                            , $color['alpha']
            );
            @imagecolortransparent($dest, $allocated);
            @imagefill($dest, 0, 0, $allocated);
        }
    }
protected function preserveAlpha ( $ dest , $ src ) { $ transparent = @ imagecolortransparent ( $ src ) ; if ( - 1 != $ transparent ) { $ color = @ imagecolorsforindex ( $ src , $ transparent ) ; $ allocated = @ imagecolorallocatealpha ( $ dest , $ color [ 'red' ] , $ color [ 'green' ] , $ color [ 'blue' ] , $ color [ 'alpha' ] ) ; @ imagecolortransparent ( $ dest , $ allocated ) ; @ imagefill ( $ dest , 0 , 0 , $ allocated ) ; } }
Preserve transparent color read from another resource on given resource

@param resource $dest the resource which the transparent color will be saved to
@param resource $src  the resource which the transparent color will be read from
Preserve transparent color read from another resource on given resource