2010-08-16 95 views
2

我想創建透明膠片的PNG圖像的輪廓。 這裏是我的代碼PHP GD:透明圖像模糊


//file that i am working with 
$file='http://www.google.com/mapfiles/turkey.png'; 
$im =imagecreatefrompng($file); 
imagealphablending($im, false); 
imagesavealpha($im, true); 
$imw  =imagesx($im); 
$imh  =imagesy($im); 
//turkey body color 
$bodycolor=imagecolorallocatealpha($im, 144, 144, 144, 50); 
//imageholder 
$imnew =imagecreatetruecolor($imh, $imh); 
imagealphablending($imnew, false); 
imagesavealpha($imnew, true); 
$transparent_color=imagecolorallocatealpha($imnew, 0, 0, 0, 127); 
imagecolortransparent($imnew, $transparent_color); 
imagefilledrectangle($imnew, 0, 0, $imh, $imh, $transparent_color); 
for ($i=0; $i > 24; 
     //all not transparent pixels are copied to imageholder 
     if ($alpha != 127) 
      { 
      imagesetpixel($imnew, $i, $j, $bodycolor); 
      } 
     } 
    } 
//blur filter 
imagefilter($imnew, IMG_FILTER_GAUSSIAN_BLUR); 
imagefilter($imnew, IMG_FILTER_GAUSSIAN_BLUR); 
imagefilter($imnew, IMG_FILTER_GAUSSIAN_BLUR); 
header ("Content-type: image/png"); 
imagepng ($imnew); 
imagedestroy ($imnew); 
?> 

所以,我需要得到剪影OT了土耳其與邊緣模糊。我現在得到的東西看起來像link text。我需要邊緣在「外部」模糊,所以像素距離邊緣越遠,使用相同的rbg就越透明。而imagefilter也舉起火雞一點:) 請幫助,我試圖解決這個問題。

回答

0

對於更復雜的圖像操作這樣的,我會強烈建議您使用ImageMagick的:http://www.imagemagick.org

這是很容易安裝你們的服務器,速度非常快,具有很大的文檔。他們有你正在談論的整個部分:http://www.imagemagick.org/Usage/channels/

+0

不幸的是,我不能在我的服務器上使用Imagick。但感謝回覆:) – Tim 2010-08-16 08:56:21