0

那么如何使用 PHP:s imagerotate 旋转 GIF 图像而不使黑色背景出现在图像上?

我已经尝试了几个小时,但它仍然无法正常工作。这是我到目前为止得到的:

        $degrees = 90.0;

        if($size['mime'] == 'image/gif') {
            $rotate = imagecreatefromgif($viewFile);
            $rotate = imagerotate($rotate, $degrees, imagecolorallocatealpha($rotate, 0, 0, 0, 127), 0);
            imagealphablending($rotate, false);
            imagesavealpha($rotate, true);
            if ($rotate != false) {
                imagegif($rotate, $viewFile, 100);
            }
            else {
                exit();
            }
        }

基于此,我已经尝试了所有我能想到的.. PNG 文件运行良好,只有 GIF:s 不起作用。

4

0 回答 0