0

我提供了一个带有 php gd 版本 2 的托管计划,我无法安装任何其他库。我知道可以使用 imagesx() imagesy() 和 imagecreatetruecolor() 来完成图像翻转,但它们在 GD 版本 2 中不可用。我无法升级到更高版本。那么,有没有其他方法可以使用 php gd 版本 2 或仅使用 php 水平和垂直翻转图像?谢谢百万。

4

1 回答 1

0

也许这会有所帮助...您需要将其修改为垂直翻转...

$size_x = imagesx($img);
$size_y = imagesy($img);

$temp = imagecreatetruecolor($size_x, $size_y);

imagecolortransparent($temp, imagecolorallocate($temp, 0, 0, 0));
imagealphablending($temp, false);
imagesavealpha($temp, true);
$x = imagecopyresampled($temp, $img, 0, 0, ($size_x-1), 0, $size_x, $size_y, 0-$size_x, $size_y);
if ($x) {
    $img = $temp;
}
else {
    die("Unable to flip image");
}

header("Content-type: image/gif");
imagegif($img);
imagedestroy($img);

归功于马库斯这是链接

于 2012-09-24T14:45:11.693 回答