0
我需要拍攝一張圖片並將其向上移動1 px在某些情況下用於我的代碼,但是使用什麼GD函數來實現?我找不到其他問題,所以我問了這個問題。但圖片的中間是一個數字,背景是透明的,高度和寬度幾乎總是不同的PHP GD移動圖片Up 1 Px
我需要拍攝一張圖片並將其向上移動1 px在某些情況下用於我的代碼,但是使用什麼GD函數來實現?我找不到其他問題,所以我問了這個問題。但圖片的中間是一個數字,背景是透明的,高度和寬度幾乎總是不同的PHP GD移動圖片Up 1 Px
下面是一個例子。關鍵部分是imagecopymerge()
函數。玩它的0,0,1,0值。
<?php
$src = imagecreatefromgif($img);
list($w,$h) = getimagesize($img);
$sprite = imagecreatetruecolor($w,$h);
$trans = imagecolortransparent($sprite);
imagealphablending($sprite, false);
imagesavealpha($sprite, true);
imagepalettecopy($sprite,$src);
imagefill($sprite,0,0,imagecolortransparent($src));
imagecolortransparent($sprite,imagecolortransparent($src));
imagecopy($sprite,$src,0,0,1,0,$w,$h);
imagegif($sprite,$img);
imagedestroy($sprite);
imagedestroy($src);
?>
你能解釋一下你的情況/你想完成什麼嗎?我不認爲使用GD等圖形庫是將圖像移動一個像素的最佳解決方案。 – 2012-03-19 12:27:38
你可能是指*裁剪1px圖像的頂部*? (提示提示,關鍵字關鍵字,谷歌谷歌) – deceze 2012-03-19 12:56:52
裁剪是一個很好的主意,謝謝你! – 2012-03-19 21:03:17