2012-09-24 45 views
0

我提供了一個使用php gd版本2的託管計劃,我無法安裝任何其他庫。我知道圖像翻轉可以通過使用imagesx()imagesy()和imagecreatetruecolor()來完成,但它們在GD版本2中不可用,並且我無法升級到更高版本。 那麼,有沒有其他方式來使用PHP gd version 2水平或垂直翻轉圖像,或者只是使用php?感謝數百萬。使用php翻轉圖片

+1

很可能不會幫助你的具體情況,但你可以在幾乎每個瀏覽器中使用CSS翻轉圖像:http://css-tricks.com/snippets/css/flip-an-image/。 –

+0

@RichBradshaw非常感謝,但可以通過CSS保存在服務器中的新圖像翻轉?我對CSS很陌生。謝謝。 – ATZ

+0

不,但有時候沒關係,取決於你想要做什麼。 –

回答

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); 

感謝MarkusHere is the link