|
一、安裝GD庫(kù) 1.編輯PHP配置文件—php.ini 2.啟用extension=php_gd2.dll選項(xiàng) 3.復(fù)制PHP安裝目錄extphp_gd2.dll到C:windowssystem32 4.復(fù)制PHP安裝目錄extphp_gd2.dll到apache安裝目錄下的bin目錄中 5.重新啟動(dòng)apache 二、GD函數(shù)庫(kù) 1.gd_info():得到gd庫(kù)的信息 語(yǔ)法:array gd_info(),返回?cái)?shù)組,包含gd庫(kù)的信息 2.√imagecreate():創(chuàng)建基于調(diào)色板的圖像 語(yǔ)法:resource imagecreate($width,$height),返回一個(gè)圖像標(biāo)識(shí)符,一個(gè)資源,創(chuàng)建出了一個(gè)指定尺寸的畫布 3.√imagecreatetruecolor():創(chuàng)建基于真彩色的圖像 語(yǔ)法:resource imagecreatetruecolor($width,$height),返回了一個(gè)圖像標(biāo)識(shí)符號(hào),代表了一個(gè)指定尺寸的黑色圖像 4.√imagegif():以GIF格式將圖像輸出到瀏覽器或者保存為文件 語(yǔ)法:bool imagegif($image[,$filename]),$image是創(chuàng)建好的圖像標(biāo)識(shí)符號(hào),$filename 是你要保存的文件名 5.√imagejpeg():以JPG或者JPEG格式將圖像輸出到瀏覽器或者保存為文件 語(yǔ)法:bool imagejpeg($image[,$filename]), $image是創(chuàng)建好的圖像標(biāo)識(shí)符號(hào),$filename是你要保存的文件名 6.√imagepng():以PNG格式將圖像輸出到瀏覽器或者保存為文件 語(yǔ)法:bool imagepng($image[,$filename]), $image是創(chuàng)建好的圖像標(biāo)識(shí)符 號(hào),$filename是你要保存的文件名 7.√imagedestroy():銷毀圖像 語(yǔ)法:bool imagedestroy($image),$image是創(chuàng)建好的圖像標(biāo)識(shí)符 8.√imagecolorallocate():創(chuàng)建顏色 語(yǔ)法:imagecolorallocate($image,$red,$green,$blue) 9.√imagefill():區(qū)域填充 語(yǔ)法:bool imagefill($image,$x,$y,$color),在圖像$image圖像的坐標(biāo)$x,$y(也就是圖像左上角0,0坐標(biāo))處用$color進(jìn)行區(qū)域填充(即與$x,$y點(diǎn)顏色相同且相鄰的點(diǎn)都會(huì)被填充),如果是對(duì)一個(gè)創(chuàng)建好的畫布填充的話,就直接寫imagefill($image,0,0,$color)就可以 10.√imagechar():水平繪制單個(gè)字符 語(yǔ)法:bool imagechar($image,$font,$x,$y,$char,$color),$font的值為1~5之間 11.imagecharup():垂直繪制單個(gè)字符 語(yǔ)法:bool imagecharup($image,$font,$x,$y,$char,$color) 12.√imagestring():水平的畫一行字符串 語(yǔ)法:bool imagestring($image,$font,$x,$y,$string,$color) 13.√imagettftext():使用TrueType字體向圖像寫入文本 語(yǔ)法:array imagettftext($image,$size,$angle,$x,$y,$color,$font,$text) $image是創(chuàng)建好的圖像資源,$size是字體大小,$angle是角度,$x,$y是坐標(biāo),$color 是創(chuàng)建好的顏色,$font是TrueType字體,$text是文本 14.imagerectangle():畫一個(gè)矩形 語(yǔ)法:bool imagerectangle($image,$x1,$y1,$x2,$y2,$color),畫一個(gè)矩形,它的左上角坐標(biāo)為$x1,$y1,右下角坐標(biāo)為$x2,$y2 15.√imagefilledrectangle():畫一矩形并填充 語(yǔ)法:imagefilledrectangle($image,$x1,$y1,$x2,$y2,$color), 畫一個(gè)矩形,它的左上角坐標(biāo)為$x1,$y1,右下角坐標(biāo)為$x2,$y2,而且是用$color來(lái)填充這個(gè)畫好的矩形 16.imagearc():畫橢圓弧 語(yǔ)法:imagearc($image,$cx,$cy,$w,$h,$s,$e,$color),$image代表圖像資源,$cx,$cy代表圖像上的坐標(biāo)點(diǎn),就是通過(guò)$cx和$cy得到這個(gè)橢圓的圓心點(diǎn)的位置,$w,$h代表橢圓的寬度和高度,$s和$e代表畫這個(gè)橢圓的起始點(diǎn)和結(jié)束點(diǎn),$color代表畫筆顏色,0度位于3點(diǎn)鐘方向,并且順時(shí)針?lè)较虍嫛?/p> 17.√imagefilledarc():畫一個(gè)橢圓弧并填充 語(yǔ)法:imagefilledarc($image,$cx,$cy,$w,$h,$s,$e,$color,$style),$style的值為: 1》IMG_ARC_PIE:產(chǎn)生圓形邊界 2》IMG_ARC_CHORD:用直線連接了起始點(diǎn)和結(jié)束點(diǎn) 3》IMG_ARC_NOFILL:指明了弧或者弦只有輪廓不填充 4》IMG_ARC_EDGED:指明用直線將起始和結(jié)束點(diǎn)與中心點(diǎn)相連。 18.imageellipse():畫一個(gè)橢圓 語(yǔ)法:bool imageellipse($im,$cx,$cy,$w,$h,$color) 19.imagefilledellipse():畫一個(gè)橢圓并填充 語(yǔ)法:bool imagefilledellipse($image,$cx,$cy,$w,$h,$color) 20.imageploygon():畫一個(gè)多邊形 語(yǔ)法:bool imageploygon($image,$points,$num_point,$color),$points是這個(gè)多邊形的點(diǎn)的坐標(biāo),是一個(gè)數(shù)組,$num_point是有幾個(gè)點(diǎn) 21.imagefilledploygon():畫一個(gè)多邊形并填充 語(yǔ)法:bool imagefilledploygon($image,$points,$num_point,$color) 22.√imagesetpixel():畫單個(gè)像素點(diǎn) 語(yǔ)法:imagesetpixel($image,$x,$y,$color) 23.√imageline():畫一條線段 語(yǔ)法:imageline($image,$x1,$y1,$x2,$y2,$color) 24.√imagecreatefromgif():從已有的GIF文件創(chuàng)建一圖像 語(yǔ)法:imagecreatefromgif($filename) 25.√imagecreatefromjpeg():從已有的JPEG文件創(chuàng)建一圖像 語(yǔ)法:imagecreatefromjpeg() 26.√imagecreatefrompng():從已有的PNG文件創(chuàng)建一圖像 語(yǔ)法:imagecreatefrompng() 27.√getimagesize():取得圖像大小 語(yǔ)法:array getimagesize($filename[,$imageinfo]),檢測(cè)圖片類型文件的尺寸、文件類型和返回用于HTML中<img/>標(biāo)記中的height和width的文本字符串如果不能訪問(wèn)$filename指定的圖像或者不是有效的圖像,它將返回false 返回?cái)?shù)組。索引0包含圖像的寬度,索引1包含圖像的高度。索引2是圖像類型1 = GIF,2 = JPG,3 = PNG,4 = SWF,5 = PSD,6 = BMP,7 = TIFF(intel byte order),8 = TIFF(motorola byte order),9 = JPC,10 = JP2,11 = JPX,12 = JB2,13 = SWC,14 = IFF, 15 = WBMP,16 = XBM。,索引3返回的height=”xx” width=”xx”,可以直接用于<img /> 標(biāo)記內(nèi)。返回的關(guān)聯(lián)bits每種顏色的位數(shù)。返回的關(guān)聯(lián)channels對(duì)于RGB 圖像其值為3,對(duì)于CMYK 圖像其值為4。返回的關(guān)聯(lián)mime,代表文件的mime類型。 28.√image_type_to_mime_type():取得getimagesize所返回的圖像類型的mime類型 語(yǔ)法:image_type_to_mime_type($type) 29.√image_type_to_extension():取得getimagesize所返回的圖像類型的擴(kuò)展名 語(yǔ)法:image_type_to_extension($type[,$include_dot]),返回?cái)U(kuò)展名,如果設(shè)置了 $include_dot=false,返回的擴(kuò)展名不包含點(diǎn),默認(rèn)的$include_dot=true. 30.√imagecopyresampled():重采樣拷貝部分圖像并調(diào)整大小 語(yǔ)法: imagecopyresampled($dst_image,$src_image,$dst_x,$dst_y,$src_x,$src_y,$dst_w,$dsth, $src_w,$src_h) 31.imagecolorallocatealpha():創(chuàng)建一個(gè)顏色,可以指明透明度 語(yǔ)法:imagecolorallocatealpha($image,$red,$green,$blue,$alpha),和imagecolorallocate 函數(shù)一樣都是創(chuàng)建一個(gè)顏色,唯一的區(qū)別是$alpha,透明度,透明度范圍為0~127,如果設(shè)置為0代表不透明,127代表完全透明。
信息發(fā)布:廣州名易軟件有限公司 http://www.jetlc.com
|