php影像處理簡單一實例

來源:互聯網
上載者:User

imagecreatetruecolor()返回一個映像標識符代表指定大小的黑色形象。

根據你的php教程和gd版本中函數定義與否。對於php 4.0.6通過4.1.x這個函數總是存在的


*/
$im=imagecreatetruecolor(100,100);        //建立映像
$string='n';            //定義字元
$white=imagecolorallocate($im,255,255,255);      //定義白色
$black=imagecolorallocate($im,0,0,0);       //定義黑色
$red=imagecolorallocate($im,255,0,0);       //定義紅色
//在白色的背景上輸出一個黑色的"z",其實是顛倒的n
imagecharup($im,6,20,20,$string,$white);
imagechar($im,2,40,40,"r",$red);        //使用紅色畫出字元
header('content-type: image/png');        //輸出頭部資訊
imagepng($im);            //輸出png檔案
imagedestroy($im);         //銷毀映像

//

$img=imagecreatetruecolor(400,400);      //建立映像
$white=imagecolorallocate($img,255,255,255);     //定義白色
$black=imagecolorallocate($img,0,0,0);      //定義黑色
imagearc($img,200,200,350,350,0,360,$white);     //畫橢圓弧
header("content-type: image/png");       //輸出頭資訊
imagepng($img);          //輸出為png映像
imagedestroy($img);          //銷毀映像

//
$size=300;
$image=imagecreatetruecolor($size,$size);
//用白色背景加黑色邊框畫個方框
$back=imagecolorallocate($image,255,255,255);
$border=imagecolorallocate($image,0,0,0);
imagefilledrectangle($image,0,0,$size-1,$size-1,$back);
imagerectangle($image,0,0,$size-1,$size-1,$border);
$yellow_x=100;
$yellow_y=75;
$red_x=120;
$red_y=165;
$blue_x=187;
$blue_y=125;
$radius=150;
//用alpha值分配一些顏色
$yellow=imagecolorallocatealpha($image,255,255,0,75);
$red=imagecolorallocatealpha($image,255,0,0,75);
$blue=imagecolorallocatealpha($image,0,0,255,75);
//畫三個交迭的圓
imagefilledellips教程e($image,$yellow_x,$yellow_y,$radius,$radius,$yellow);
imagefilledellipse($image,$red_x,$red_y,$radius,$radius,$red);
imagefilledellipse($image,$blue_x,$blue_y,$radius,$radius,$blue);
//輸出header檔案頭
header('content-type: image/png');
//最後輸出結果
imagepng($image);
imagedestroy($image);

//

$im=imagecreate(100,100);         //建立映像
$string='php';            //定義字串
$bg=imagecolorallocate($im,255,255,255);      //定義白色
$black=imagecolorallocate($im,0,0,0);       //定義黑色
//在左上方輸出指定字元
imagechar($im,1,0,0,$string,$black);
header('content-type: image/png');        //輸出頭部資訊
imagepng($im);            //輸出png檔案
imagedestroy($im);           //銷毀映像

?>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.