當前位置:首頁 » 編程語言 » php畫弧

php畫弧

發布時間: 2023-02-03 10:07:57

php圖像處理函數有哪些

我在網上找了半天,發現這些都無法實現對它的認識,於是我偶然間找到了相關的資料方面的書;

那就是PHP 手冊,表在網上找這些沒用的東西了,全是些皮毛介紹,誤人子弟;

請點擊這里:網頁鏈接下載相關的手冊,或者在網上查找PHP相關的中文版的手冊;

又全面又仔細,不需要在網上亂查了,根本就是浪費時間,誤入歧途.

例子 1. 用 PHP 創建 PNG 圖像

<?phpheader("Content-type: image/png");

$string = $_GET['text'];

$im= imagecreatefrompng("images/button1.png");

$orange = imagecolorallocate($im,
220, 210, 60);

$px= (imagesx($im) - 7.5
* strlen($string)) /
2;

imagestring($im, 3, $px, 9, $string, $orange);

imagepng($im);

imagedestroy($im);

?>

本例應該在一個具有類似:<img
src="button.php?text=text"> 標簽的頁面中被調用。上述的 button.php 腳本會取得 "text"
字元串將其覆蓋在原圖上(本例中的
"images/button1.png")並輸出作為結果的圖像。用此方法可以很方便地修改按鈕上的文字從而避免了每次都要新畫一個按鈕的圖像。用此方法就可以動態生成了。

  • 目錄

  • exif_imagetype--判斷一個圖像的類型

  • exif_read_data-- 從 JPEG 或 TIFF 文件中讀取 EXIF 頭信息,這樣就可以讀取數碼相機產生的元數據

  • exif_thumbnail--取得嵌入在 TIFF 或
    JPEG 圖像中的縮略圖

  • gd_info--取得當前安裝的 GD 庫的信息

  • getimagesize--取得圖像大小

  • image_type_to_mime_type-- 取得
    getimagesize,exif_read_data,exif_thumbnail,exif_imagetype 所返回的圖像類型的 MIME 類型

  • image2wbmp--以 WBMP 格式將圖像輸出到瀏覽器或文件

  • imagealphablending--設定圖像的混色模式

  • imageantialias--是否使用 antialias
    功能

  • imagearc--畫橢圓弧

  • imagechar--水平地畫一個字元

  • imagecharup--垂直地畫一個字元

  • imagecolorallocate--為一幅圖像分配顏色

  • imagecolorallocatealpha--為一幅圖像分配顏色
    + alpha

  • imagecolorat--取得某像素的顏色索引值

  • imagecolorclosest--取得與指定的顏色最接近的顏色的索引值

  • imagecolorclosestalpha--取得與指定的顏色
    + alpha 最接近的顏色

  • imagecolorclosesthwb--
    取得與給定顏色最接近的色度的黑白色的索引

  • imagecolordeallocate--取消圖像顏色的分配

  • imagecolorexact--取得指定顏色的索引值

  • imagecolorexactalpha--取得指定的顏色 +
    alpha 的索引值

  • imagecolormatch--
    使一個圖像中調色板版本的顏色與真彩色版本更能匹配

  • imagecolorresolve--
    取得指定顏色的索引值或有可能得到的最接近的替代值

  • imagecolorresolvealpha--
    取得指定顏色 + alpha 的索引值或有可能得到的最接近的替代值

  • imagecolorset--給指定調色板索引設定顏色

  • imagecolorsforindex--取得某索引的顏色

  • imagecolorstotal--取得一幅圖像的調色板中顏色的數目

  • imagecolortransparent--將某個顏色定義為透明色

  • image--拷貝圖像的一部分

  • imagemerge--拷貝並合並圖像的一部分

  • imagemergegray--用灰度拷貝並合並圖像的一部分

  • imageresampled--重采樣拷貝部分圖像並調整大小

  • imageresized--拷貝部分圖像並調整大小

  • imagecreate--新建一個基於調色板的圖像

  • imagecreatefromgd2--從 GD2
    文件或 URL 新建一圖像

  • imagecreatefromgd2part--從給定的
    GD2 文件或 URL 中的部分新建一圖像

  • imagecreatefromgd--從 GD 文件或
    URL 新建一圖像

  • imagecreatefromgif--從 GIF
    文件或 URL 新建一圖像

  • imagecreatefromjpeg--從
    JPEG 文件或 URL 新建一圖像

  • imagecreatefrompng--從 PNG
    文件或 URL 新建一圖像

  • imagecreatefromstring--從字元串中的圖像流新建一圖像

  • imagecreatefromwbmp--從
    WBMP 文件或 URL 新建一圖像

  • imagecreatefromxbm--從 XBM
    文件或 URL 新建一圖像

  • imagecreatefromxpm--從 XPM
    文件或 URL 新建一圖像

  • imagecreatetruecolor--新建一個真彩色圖像

  • imagedashedline--畫一虛線

  • imagedestroy--銷毀一圖像

  • imageellipse--畫一個橢圓

  • imagefill--區域填充

  • imagefilledarc--畫一橢圓弧且填充

  • imagefilledellipse--畫一橢圓並填充

  • imagefilledpolygon--畫一多邊形並填充

  • imagefilledrectangle--畫一矩形並填充

  • imagefilltoborder--區域填充到指定顏色的邊界為止

  • imagefontheight--取得字體高度

  • imagefontwidth--取得字體寬度

  • imageftbbox--取得使用了 FreeType 2
    字體的文本的范圍

  • imagefttext--使用 FreeType 2
    字體將文本寫入圖像

  • imagegammacorrect--對 GD 圖像應用
    gamma 修正

  • imagegd2--輸出 GD2 圖像

  • imagegd--將 GD 圖像輸出到瀏覽器或文件

  • imagegif--以 GIF 格式將圖像輸出到瀏覽器或文件

  • imageinterlace--激活或禁止隔行掃描

  • imageistruecolor--檢查圖像是否為真彩色圖像

  • imagejpeg--以 JPEG 格式將圖像輸出到瀏覽器或文件

  • imagelayereffect-- Set the
    alpha blending flag to use the bundled libgd layering effects

  • imageline--畫一條直線

  • imageloadfont--載入一新字體

  • imagepalette--將調色板從一幅圖像拷貝到另一幅

  • imagepng--以 PNG 格式將圖像輸出到瀏覽器或文件

  • imagepolygon--畫一個多邊形

  • imagepsbbox--取得使用 PostScript Type1
    字體的文本的范圍

  • imagepsfont--
    拷貝一個已載入的字體以備更改

  • imagepsencodefont--改變字體中的字元編碼矢量

  • imagepsextendfont--擴充或壓縮字體

  • imagepsfreefont--釋放一個
    PostScript Type 1 字體所佔用的內存

  • imagepsloadfont--從文件中載入一個
    PostScript Type 1 字體

  • imagepsslantfont--傾斜某字體

  • imagepstext--用 PostScript Type1
    字體把文本字元串畫在圖像上

  • imagerectangle--畫一個矩形

  • imagerotate--用給定角度旋轉圖像

  • imagesavealpha-- 設置標記以在保存 PNG
    圖像時保存完整的 alpha 通道信息(與單一透明色相反)

  • imagesetbrush--設定畫線用的畫筆圖像

  • imagesetpixel--畫一個單一像素

  • imagesetstyle--設定畫線的風格

  • imagesetthickness--設定畫線的寬度

  • imagesettile--設定用於填充的貼圖

  • imagestring--水平地畫一行字元串

  • imagestringup--垂直地畫一行字元串

  • imagesx--取得圖像寬度

  • imagesy--取得圖像高度

  • imagetruecolortopalette--將真彩色圖像轉換為調色板圖像

  • imagettfbbox--取得使用 TrueType
    字體的文本的范圍

  • imagettftext--用 TrueType
    字體向圖像寫入文本

  • imagetypes--返回當前 PHP 版本所支持的圖像類型

  • imagewbmp--以 WBMP 格式將圖像輸出到瀏覽器或文件

  • iptcembed--將二進制 IPTC 數據嵌入到一幅 JPEG
    圖像中

  • iptcparse-- 將二進制 IPTC http://www.iptc.org/ 塊解析為單個標記

  • jpeg2wbmp--將 JPEG 圖像文件轉換為 WBMP 圖像文件

  • png2wbmp--將 PNG 圖像文件轉換為 WBMP 圖像文件

  • read_exif_data--exif_read_data() 的別名

② 在PHOTOSHOP中怎樣把畫布的四個角變成圓弧角

這個我會啦!你把圖片拉到PS後,按住Ctrl同時點擊當前圖層,此時當前圖層成為選區,松開Ctrl.然後Ctrl+Alt+D羽化選區,Ctrl+Shift+I反相選區,直接按Delete.然後再適當的將圖層放大,看你想要的效果了!!我的這個方法絕對OK!我以前做過啊!

③ 如何在PHP中開啟GD庫支持詳解

開啟GD庫是php中一個重要的參數,常用來處理圖像,像圖片的任何處理都需要GD庫的支持,下面我來介紹各種系統中GD庫的開啟方法與命令,大家可參考。

Windows下開啟PHP的GD庫支持
找到php.ini,打開內容,找到:
;extension=php_gd2.dll
把最前面的分號「;」去掉,再保存即可,如果本來就沒有分號,那就是已經開啟了。
linux下開啟PHP的GD庫支持
#開啟GD庫支持有以下幾種方法
##檢測GD庫是否安裝命令
php5 -m | grep -i gd
或者
php -i | grep -i --color gd
##如未安裝GD庫,則為伺服器安裝,方法如下
### 如果是源碼安裝,則加入參數
--with-gd
### 如果是debian系的linux系統,用apt-get安裝,如下
apt-get install php5-gd
### 如果是CentOS系的系統,用yum安裝,如下
yum install php-gd
### 如果是suse系的linux系統,用yast安裝,如下
yast -i php5_gd
### 如果嫌這個世界不夠蛋疼呢,可以在原先編譯PHP不支持GD的情況下附加
先下zlib源碼,libpng源碼,gd源碼
解壓後到源碼目錄
zlib目錄
./configure --prefix=/usr/local/zlib
make ; make install
make clean
libpng目錄
cp scripts/makefile.linux ./makefile
./configure --prefix=/usr/local/libpng
make ; make install
make clean
gd目錄
./configure --prefix=/usr/local/libgd --with-png=/usr/local/libpng
make ; make install
make clean
最後在php.ini中,搜到[gd]後,在下面加一行
extension=/usr/local/libgdgd.so
然後重啟php服務,如果不行,試試reboot
好了,不過最後提醒一下,要知道這個世界很多意外的,源碼安裝,只添加gd庫這一個情況下,PHP版本和庫的版本各異
,所以:
- 不保證這么付出了這么多後有回報
- 不保證能夠成功載入gd.so
- 不保證不懷孕
所以如果是源碼安裝,最好還是在編譯PHP的時候加參數--with-gd

GD庫函數
GetImageSize
作用:取得圖片的大小[即長與寬] 用法:array GetImageSize(string filename, array [imageinfo]);
ImageArc
作用:畫弧線 用法:int ImageArc(int im, int cx, int cy, int w, int h, int s, int e, int col);
ImageChar
作用:寫出橫向字元 用法:int ImageChar(int im, int font, int x, int y, string c, int col);
ImageCharUp
作用:寫出豎式字元 用法:int ImageCharup(int im, int font, int x, int y, string c, int col);
ImageColorAllocate
作用:匹配顏色 用法:int ImageColorAllocate(int im, int red, int green, int blue);

ImageColorTransparent
作用:指定透明背景色 用法:int ImageColorTransparent(int im, int [col]);

ImageCopyResized
作用:復制新圖並調整大小 用法:int ImageCopyResized(int dst_im, int src_im, int dstX, int dstY, int srcX,
int srcY, int dstW, int dstH, int srcW, int srcH);

ImageCreate
作用:建立新圖 用法:int ImageCreate(int x_size, int y_size);

ImageDashedLine
作用:繪虛線 用法:int ImageDashedLine(int im, int x1, int y1, int x2, int y2, int col);
ImageDestroy 作用:結束圖形 用法解釋:int ImageDestroy(int im);

ImageFill
作用:圖形著色 用法:int ImageFill(int im, int x, int y, int col);
ImageFilledPolygon作用:多邊形區域著色 用法:int ImageFilledPolygon(int im, array points, int num_points,
int col);

ImageFilledRectangle作用:矩形區域著色 用法:int ImageFilledRectangle(int im, int x1, int y1, int x2, int
y2, int col);

ImageFillToBorder作用:指定顏色區域內著色 用法:int ImageFillToBorder(int im, int x, int y, int border,
int col);

ImageFontHeight
作用:取得字型的高度 用法:int ImageFontHeight(int font);

ImageFontWidth作用:取得字型的寬度 用法:int ImageFontWidth(int font);

ImageInterlace作用:使用交錯式顯示與否 用法:int ImageInterlace(int im, int [interlace]);

ImageLine作用:繪實線 用法:int ImageLine(int im, int x1, int y1, int x2, int y2, int col);

ImageLoadFont作用:載入點陣字型 用法:int ImageLoadFont(string file);

ImagePolygon作用:繪多邊形 用法:int ImagePolygon(int im, array points, int num_points, int col);

ImageRectangle作用:繪矩形 用法:int ImageRectangle(int im, int x1, int y1, int x2, int y2, int col);

ImageSetPixel作用:繪點 用法:int ImageSetPixel(int im, int x, int y, int col); ImageString 作用:繪橫式
字元串 用法:int ImageString(int im, int font, int x, int y, string s, int col);

ImageStringUp作用:繪直式字元串 用法:int ImageStringUp(int im, int font, int x, int y, string s, int
col);

ImageSX
作用:取得圖片的寬度 用法:int ImageSX(int im);

ImageSY
作用:取得圖片的高度 用法:int ImageSY(int im);

ImageTTFBBox
作用:計算 TTF 文字所佔區域 用法:array ImageTTFBBox(int size, int angle, string fontfile, string text);

ImageTTFText作用:寫 TTF 文字到圖中 用法:array ImageTTFText(int im, int size, int angle, int x, int y,
int col, string fontfile, string text); ImageColorAt 作用:取得圖中指定點顏色的索引值 用法:int
ImageColorAt(int im, int x, int y);

ImageColorClosest
作用:計算色表中與指定顏色最接近者 用法:int ImageColorClosest(int im, int red, int green, int blue);

ImageColorExact
作用:計算色表上指定顏色索引值 用法:int ImageColorExact(int im, int red, int green, int blue);

ImageColorResolve
作用:計算色表上指定或最接近顏色的索引值 用法:int ImageColorResolve(int im, int red, int green, int
blue);
ImageColorSet
作用:設定色表上指定索引的顏色 用法:boolean ImageColorSet(int im, int index, int red, int green, int
blue); ImageColorsForIndex 作用:取得色表上指定索引的顏色 用法:array ImageColorsForIndex(int im, int
index);

ImageColorsTotal
作用:計算圖的顏色數 用法:int ImageColorsTotal(int im); ImagePSLoadFont 作用:載入 PostScript 字型 用法
:int ImagePSLoadFont(string filename);

ImagePSFreeFont
作用:卸下 PostScript 字型 用法:void ImagePSFreeFont(int fontindex);

ImagePSEncodeFont
作用:PostScript 字型轉成向量字 用法:int ImagePSEncodeFont(string encodingfile);

ImagePSText作用:寫 PostScript 文字到圖中 用法:array ImagePSText(int image, string text, int font, int
size, int foreground, int background, int x, int y, int space, int tightness, float angle, int
antialias_steps);

ImagePSBBox作用:計算 PostScript 文字所佔區域 用法: array ImagePSBBox(string text, int font, int size,
int space, int width, float angle);

ImageCreateFromPNG作用:取出 PNG 圖型 用法:int ImageCreateFromPng(string filename);

ImagePNG作用:建立 PNG 圖型 用法:int ImagePng(int im, string [filename]);

ImageCreateFromGIF作用:取出 GIF 圖型 用法:int ImageCreateFromGif(string filename);

ImageGIF作用:建立 GIF 圖型 用法:int ImageGif(int im, string [filename]);

④ php中imagettftext()函數的使用~ 呢

共有8個參數,缺一不可:
(1)$image 這個是畫布資源,無需再解釋;
(2)$size,官方文檔的解釋是,字體大小,其長度單位依賴於GD庫的版本,對於GD1來說是像素,對於GD2來說是磅(point)。現在一般都是GD2了,那麼這個磅究竟是什麼意思呢?這涉及到字體設計的基本知識。
操作點陣圖時,以像素位單位最精確合理,那麼使用GD2庫的時候,如何繪制大小為20像素的字呢?也就是多少磅才能等於20個像素呢?這必須通過解析度才能計算出來,而問題是點陣圖本身並沒有解析度的概念。
現在把問題返回來,如果給定$size=20磅,那麼imageTtfText()繪制完成時,究竟會佔用多少像素。無論如何,imageTtfText()最終還是要把文字繪制落實到具體的點陣圖像素上。
這個問題確實非常棘手,此函數內部必然會使用某個解析度PPI來計算被渲染的像素區域。而GD2庫卻沒有提供任何讓用戶設置或者讀取這個解析度的方法。那麼,我們只能動手測試了。使用不同的磅值繪制文字,然後測量文字占據的像素,通過公式:
PPI = (72*像素數)/磅值。實驗得出的結論是:
[plain] view plainprint?
1磅==>4像素, PPI=288
2磅==>5像素, PPI=180
3磅==>7像素, PPI=168
4磅==>8像素, PPI=144
5磅==>9像素, PPI=129.6
6磅==>10像素, PPI=120
7磅==>11像素, PPI=113.14285714286
8磅==>12像素, PPI=108
9磅==>14像素, PPI=112
10磅==>15像素, PPI=108
11磅==>16像素, PPI=104.72727272727
12磅==>17像素, PPI=102
13磅==>18像素, PPI=99.692307692308
14磅==>19像素, PPI=97.714285714286
15磅==>21像素, PPI=100.8
16磅==>22像素, PPI=99
17磅==>23像素, PPI=97.411764705882
18磅==>25像素, PPI=100
19磅==>26像素, PPI=98.526315789474
20磅==>27像素, PPI=97.2
21磅==>28像素, PPI=96
22磅==>29像素, PPI=94.909090909091
23磅==>30像素, PPI=93.913043478261
24磅==>32像素, PPI=96
25磅==>33像素, PPI=95.04
26磅==>34像素, PPI=94.153846153846
27磅==>35像素, PPI=93.333333333333
28磅==>36像素, PPI=92.571428571429
29磅==>38像素, PPI=94.344827586207
30磅==>39像素, PPI=93.6
31磅==>40像素, PPI=92.903225806452
32磅==>41像素, PPI=92.25
33磅==>43像素, PPI=93.818181818182
34磅==>44像素, PPI=93.176470588235
35磅==>46像素, PPI=94.628571428571
36磅==>47像素, PPI=94
37磅==>48像素, PPI=93.405405405405
38磅==>48像素, PPI=90.947368421053
39磅==>50像素, PPI=92.307692307692
40磅==>51像素, PPI=91.8
41磅==>52像素, PPI=91.317073170732
42磅==>53像素, PPI=90.857142857143
43磅==>55像素, PPI=92.093023255814
44磅==>56像素, PPI=91.636363636364
45磅==>57像素, PPI=91.2
46磅==>58像素, PPI=90.782608695652
47磅==>60像素, PPI=91.914893617021
48磅==>62像素, PPI=93
49磅==>63像素, PPI=92.571428571429
50磅==>63像素, PPI=90.72
51磅==>64像素, PPI=90.352941176471
52磅==>67像素, PPI=92.769230769231
53磅==>68像素, PPI=92.377358490566
54磅==>69像素, PPI=92
55磅==>70像素, PPI=91.636363636364
56磅==>71像素, PPI=91.285714285714
57磅==>72像素, PPI=90.947368421053
58磅==>74像素, PPI=91.862068965517
59磅==>75像素, PPI=91.525423728814
60磅==>76像素, PPI=91.2
61磅==>77像素, PPI=90.885245901639
62磅==>78像素, PPI=90.58064516129
63磅==>79像素, PPI=90.285714285714
64磅==>81像素, PPI=91.125
65磅==>83像素, PPI=91.938461538462
66磅==>84像素, PPI=91.636363636364
67磅==>85像素, PPI=91.34328358209
68磅==>86像素, PPI=91.058823529412
69磅==>86像素, PPI=89.739130434783
70磅==>88像素, PPI=90.514285714286
71磅==>90像素, PPI=91.267605633803
72磅==>91像素, PPI=91
73磅==>92像素, PPI=90.739726027397
74磅==>93像素, PPI=90.486486486486
1磅==>4像素, PPI=288
2磅==>5像素, PPI=180
3磅==>7像素, PPI=168
4磅==>8像素, PPI=144
5磅==>9像素, PPI=129.6
6磅==>10像素, PPI=120
7磅==>11像素, PPI=113.14285714286
8磅==>12像素, PPI=108
9磅==>14像素, PPI=112
10磅==>15像素, PPI=108
11磅==>16像素, PPI=104.72727272727
12磅==>17像素, PPI=102
13磅==>18像素, PPI=99.692307692308
14磅==>19像素, PPI=97.714285714286
15磅==>21像素, PPI=100.8
16磅==>22像素, PPI=99
17磅==>23像素, PPI=97.411764705882
18磅==>25像素, PPI=100
19磅==>26像素, PPI=98.526315789474
20磅==>27像素, PPI=97.2
21磅==>28像素, PPI=96
22磅==>29像素, PPI=94.909090909091
23磅==>30像素, PPI=93.913043478261
24磅==>32像素, PPI=96
25磅==>33像素, PPI=95.04
26磅==>34像素, PPI=94.153846153846
27磅==>35像素, PPI=93.333333333333
28磅==>36像素, PPI=92.571428571429
29磅==>38像素, PPI=94.344827586207
30磅==>39像素, PPI=93.6
31磅==>40像素, PPI=92.903225806452
32磅==>41像素, PPI=92.25
33磅==>43像素, PPI=93.818181818182
34磅==>44像素, PPI=93.176470588235
35磅==>46像素, PPI=94.628571428571
36磅==>47像素, PPI=94
37磅==>48像素, PPI=93.405405405405
38磅==>48像素, PPI=90.947368421053
39磅==>50像素, PPI=92.307692307692
40磅==>51像素, PPI=91.8
41磅==>52像素, PPI=91.317073170732
42磅==>53像素, PPI=90.857142857143
43磅==>55像素, PPI=92.093023255814
44磅==>56像素, PPI=91.636363636364
45磅==>57像素, PPI=91.2
46磅==>58像素, PPI=90.782608695652
47磅==>60像素, PPI=91.914893617021
48磅==>62像素, PPI=93
49磅==>63像素, PPI=92.571428571429
50磅==>63像素, PPI=90.72
51磅==>64像素, PPI=90.352941176471
52磅==>67像素, PPI=92.769230769231
53磅==>68像素, PPI=92.377358490566
54磅==>69像素, PPI=92
55磅==>70像素, PPI=91.636363636364
56磅==>71像素, PPI=91.285714285714
57磅==>72像素, PPI=90.947368421053
58磅==>74像素, PPI=91.862068965517
59磅==>75像素, PPI=91.525423728814
60磅==>76像素, PPI=91.2
61磅==>77像素, PPI=90.885245901639
62磅==>78像素, PPI=90.58064516129
63磅==>79像素, PPI=90.285714285714
64磅==>81像素, PPI=91.125
65磅==>83像素, PPI=91.938461538462
66磅==>84像素, PPI=91.636363636364
67磅==>85像素, PPI=91.34328358209
68磅==>86像素, PPI=91.058823529412
69磅==>86像素, PPI=89.739130434783
70磅==>88像素, PPI=90.514285714286
71磅==>90像素, PPI=91.267605633803
72磅==>91像素, PPI=91
73磅==>92像素, PPI=90.739726027397
74磅==>93像素, PPI=90.486486486486

可見當大於46磅時,PPI穩定在90,而小於46磅時,PPI一直在微變。
所以,如果你想繪制20個像素大小的字體,那麼必須設置$size參數為:14.5磅。
另外需要注意的是,$size並不完全對應字體的顯示大小,因為同樣的$size,不同的字元占據的空間並不是一樣的。例如,漢字「國」的寬度會比數字1的寬度大得多,對於標點符號,則更是這樣,半形和全形符號也不同。
總之,使用imageTtfText()不可能精確控制到像素級別,只能大概。這也算是矢量字體的一個小缺陷。
(3)$angle是旋轉角度。這個官網解釋的比較清楚,需要說明有兩點:一是角度單位是度而不是弧度,二是旋轉的中心點就是參數$x,$y。
(4)$x,$y 被繪制字元串的第一個字元的基線點。單位是像素。這里涉及到字體設計的基本知識--基線。這個點絕對不是左上角,而具體是什麼取決於所使用的字體是如何設計的。對於宋體、楷體、黑體等常見的字體中的漢字,這個點大概位於字體的左下部分;而對於英文字母和標點符號,則各不相同。如下圖:
(5)$color 字體的顏色。
(6)$fontfile 字體文件。也就是包含trueType字體字模的文件,如楷體字體文件simkai.ttf。這種文件的格式是有標准規范的,而且與平台無關。所以可以直接把Windows系統的字體文件拷貝到Linux下使用。
(7)$text 要渲染的字元串。需要注意必須是UTF-8編碼的字元串。說到字元串不得不提PHP的string數據類型。雖然名為string,其實PHP語言本身並不認識各種字元編碼,它只是簡單的把string看做是動態增長的「位元組」數組,例如strlen()就是返回的位元組數。而我們知道除了ASCII編碼的字元和位元組是相同的外,幾乎沒有其他字元編碼中的字元對應一個位元組,例如一個漢字的UTF-8編碼佔用3個位元組。至於怎麼解釋其中的字元編碼,需要專門的庫函數如iconv_strlen()。如果字元串使用字面量,那麼其所在的php源文件就必須編碼為UTF-8存儲

⑤ php生成圖片輸出到前端頁面亂碼

是生成的圖像裡面有亂碼,還是頁面有亂碼?圖像裡面有亂碼在生成圖片那裡聲明下編碼格式:header("charset=UTF-8");
頁面有亂碼聲明下頁面的格式:header("Content-Type: text/html; charset=UTF-8");
兩者是有區別的。

⑥ 如何在PHP中開啟GD庫支持

Windows下開啟PHP的GD庫支持
找到php.ini,打開內容,找到:
;extension=php_gd2.dll
把最前面的分號「;」去掉,再保存即可,如果本來就沒有分號,那就是已經開啟了。
Linux下開啟PHP的GD庫支持
#開啟GD庫支持有以下幾種方法
##檢測GD庫是否安裝命令
php5 -m | grep -i gd
或者
php -i | grep -i --color gd
##如未安裝GD庫,則為伺服器安裝,方法如下
### 如果是源碼安裝,則加入參數
--with-gd
### 如果是debian系的linux系統,用apt-get安裝,如下
apt-get install php5-gd
### 如果是CentOS系的系統,用yum安裝,如下
yum install php-gd
### 如果是suse系的linux系統,用yast安裝,如下
yast -i php5_gd
### 如果嫌這個世界不夠蛋疼呢,可以在原先編譯PHP不支持GD的情況下附加
先下zlib源碼,libpng源碼,gd源碼
解壓後到源碼目錄
zlib目錄
./configure --prefix=/usr/local/zlib
make ; make install
make clean
libpng目錄
cp scripts/makefile.linux ./makefile
./configure --prefix=/usr/local/libpng
make ; make install
make clean
gd目錄
./configure --prefix=/usr/local/libgd --with-png=/usr/local/libpng
make ; make install
make clean
最後在php.ini中,搜到[gd]後,在下面加一行
extension=/usr/local/libgdgd.so
然後重啟php服務,如果不行,試試reboot
好了,不過最後提醒一下,要知道這個世界很多意外的,源碼安裝,只添加gd庫這一個情況下,PHP版本和庫的版本各異
,所以:
- 不保證這么付出了這么多後有回報
- 不保證能夠成功載入gd.so
- 不保證不懷孕
所以如果是源碼安裝,最好還是在編譯PHP的時候加參數--with-gd

GD庫函數
GetImageSize
作用:取得圖片的大小[即長與寬] 用法:array GetImageSize(string filename, array [imageinfo]);
ImageArc
作用:畫弧線 用法:int ImageArc(int im, int cx, int cy, int w, int h, int s, int e, int col);
ImageChar
作用:寫出橫向字元 用法:int ImageChar(int im, int font, int x, int y, string c, int col);
ImageCharUp
作用:寫出豎式字元 用法:int ImageCharup(int im, int font, int x, int y, string c, int col);
ImageColorAllocate
作用:匹配顏色 用法:int ImageColorAllocate(int im, int red, int green, int blue);

ImageColorTransparent
作用:指定透明背景色 用法:int ImageColorTransparent(int im, int [col]);

ImageCopyResized
作用:復制新圖並調整大小 用法:int ImageCopyResized(int dst_im, int src_im, int dstX, int dstY, int srcX,
int srcY, int dstW, int dstH, int srcW, int srcH);

ImageCreate
作用:建立新圖 用法:int ImageCreate(int x_size, int y_size);

ImageDashedLine
作用:繪虛線 用法:int ImageDashedLine(int im, int x1, int y1, int x2, int y2, int col);
ImageDestroy 作用:結束圖形 用法解釋:int ImageDestroy(int im);

ImageFill
作用:圖形著色 用法:int ImageFill(int im, int x, int y, int col);
ImageFilledPolygon作用:多邊形區域著色 用法:int ImageFilledPolygon(int im, array points, int num_points,
int col);

ImageFilledRectangle作用:矩形區域著色 用法:int ImageFilledRectangle(int im, int x1, int y1, int x2, int
y2, int col);

ImageFillToBorder作用:指定顏色區域內著色 用法:int ImageFillToBorder(int im, int x, int y, int border,
int col);

ImageFontHeight
作用:取得字型的高度 用法:int ImageFontHeight(int font);

ImageFontWidth作用:取得字型的寬度 用法:int ImageFontWidth(int font);

ImageInterlace作用:使用交錯式顯示與否 用法:int ImageInterlace(int im, int [interlace]);

ImageLine作用:繪實線 用法:int ImageLine(int im, int x1, int y1, int x2, int y2, int col);

ImageLoadFont作用:載入點陣字型 用法:int ImageLoadFont(string file);

ImagePolygon作用:繪多邊形 用法:int ImagePolygon(int im, array points, int num_points, int col);

ImageRectangle作用:繪矩形 用法:int ImageRectangle(int im, int x1, int y1, int x2, int y2, int col);

ImageSetPixel作用:繪點 用法:int ImageSetPixel(int im, int x, int y, int col); ImageString 作用:繪橫式
字元串 用法:int ImageString(int im, int font, int x, int y, string s, int col);

ImageStringUp作用:繪直式字元串 用法:int ImageStringUp(int im, int font, int x, int y, string s, int
col);

ImageSX
作用:取得圖片的寬度 用法:int ImageSX(int im);

ImageSY
作用:取得圖片的高度 用法:int ImageSY(int im);

ImageTTFBBox
作用:計算 TTF 文字所佔區域 用法:array ImageTTFBBox(int size, int angle, string fontfile, string text);

ImageTTFText作用:寫 TTF 文字到圖中 用法:array ImageTTFText(int im, int size, int angle, int x, int y,
int col, string fontfile, string text); ImageColorAt 作用:取得圖中指定點顏色的索引值 用法:int
ImageColorAt(int im, int x, int y);

ImageColorClosest
作用:計算色表中與指定顏色最接近者 用法:int ImageColorClosest(int im, int red, int green, int blue);

ImageColorExact
作用:計算色表上指定顏色索引值 用法:int ImageColorExact(int im, int red, int green, int blue);

ImageColorResolve
作用:計算色表上指定或最接近顏色的索引值 用法:int ImageColorResolve(int im, int red, int green, int
blue);
ImageColorSet
作用:設定色表上指定索引的顏色 用法:boolean ImageColorSet(int im, int index, int red, int green, int
blue); ImageColorsForIndex 作用:取得色表上指定索引的顏色 用法:array ImageColorsForIndex(int im, int
index);

ImageColorsTotal
作用:計算圖的顏色數 用法:int ImageColorsTotal(int im); ImagePSLoadFont 作用:載入 PostScript 字型 用法
:int ImagePSLoadFont(string filename);

ImagePSFreeFont
作用:卸下 PostScript 字型 用法:void ImagePSFreeFont(int fontindex);

ImagePSEncodeFont
作用:PostScript 字型轉成向量字 用法:int ImagePSEncodeFont(string encodingfile);

ImagePSText作用:寫 PostScript 文字到圖中 用法:array ImagePSText(int image, string text, int font, int
size, int foreground, int background, int x, int y, int space, int tightness, float angle, int
antialias_steps);

ImagePSBBox作用:計算 PostScript 文字所佔區域 用法: array ImagePSBBox(string text, int font, int size,
int space, int width, float angle);

ImageCreateFromPNG作用:取出 PNG 圖型 用法:int ImageCreateFromPng(string filename);

ImagePNG作用:建立 PNG 圖型 用法:int ImagePng(int im, string [filename]);

ImageCreateFromGIF作用:取出 GIF 圖型 用法:int ImageCreateFromGif(string filename);

ImageGIF作用:建立 GIF 圖型 用法:int ImageGif(int im, string [filename]);

⑦ php三維餅圖怎麼做要調入資料庫的數據!請高手指點!不會的別來混經驗!

這是個2D的。
其中有一個自定義函數,用於繪制餅圖,參數是一個鍵值對數組。
每項內容是由數組定義的。你調入資料庫中的內容後讀入數組即可。
前提是你當然要開啟GD擴展,要不是沒得畫得。呵。
<?php
function pie2d($a) //創建自定義函數
{
$im=imagecreate(420,300); //建立圖像
$back=imagecolorallocate($im,255,255,200); //背景色
$color[]=imagecolorallocate($im,0,0,255); //定義10個顏色,可以最多處理10項
$color[]=imagecolorallocate($im,255,0,0);
$color[]=imagecolorallocate($im,0,255,0);
$color[]=imagecolorallocate($im,100,100,255);
$color[]=imagecolorallocate($im,255,0,255);
$color[]=imagecolorallocate($im,150,0,0);
$color[]=imagecolorallocate($im,0,0,150);
$color[]=imagecolorallocate($im,0,150,0);
$color[]=imagecolorallocate($im,0,0,0);
$color[]=imagecolorallocate($im,150,150,150);
$value_a=array_values($a); //獲取參數數組所有值到新數組
$all=array_sum($value_a); //統計新數組的和
$i=0; //循環標記
foreach($a as $key=>$value) //遍歷數組
{
$angle[]=$value/$all*360; //獲取當前角度
$str=$key.":".round($value/$all*100,2)."%"; //需要輸出的內容
imagestring($im,5,10,($i*20+10),$str,$color[$i]); //畫字元串
$i++; //標記自增
}
$s=0; //當前角度標記
$i=0;
foreach($angle as $temp) //遍歷所有項角度
{
imagefilledarc($im,285,150,240,120,$s,($s+$temp),$color[$i],4); //畫橢圓弧
//imagefillellipse();
$s=$s+$temp; //角度增加為當前角度
$i++;
}
imagepng($im); //輸出PNG
imagedestroy($im); //銷毀圖像
}
$arr=array(
"perfect"=>1,
"excellent"=>2,
"very good"=>4,
"good"=>1,
"not bad"=>1,
"normal"=>1,
"bad"=>1,
"very bad"=>1,
"god save me"=>1,
"hell"=>1
); //定義數組,數組內容為選項內容與選項數量的鍵值對
$re=pie2d($arr); //調用自定義函數
?>

熱點內容
腳本注入到其他軟體運行 發布:2024-03-28 18:30:02 瀏覽:720
網易我的世界皮膚能用到伺服器嗎 發布:2024-03-28 18:24:44 瀏覽:804
access資料庫數據類型 發布:2024-03-28 18:16:04 瀏覽:301
安卓界面如何變成蘋果手機界面 發布:2024-03-28 18:07:17 瀏覽:742
方舟手游如何卡安卓大廳會員 發布:2024-03-28 17:52:37 瀏覽:241
空域銳化演算法 發布:2024-03-28 17:52:32 瀏覽:500
虎牙安卓版是什麼意思 發布:2024-03-28 17:43:10 瀏覽:861
電腦改成雲伺服器 發布:2024-03-28 17:37:50 瀏覽:266
文件夾審計 發布:2024-03-28 17:08:20 瀏覽:242
密碼反編譯是什麼意思 發布:2024-03-28 17:02:54 瀏覽:310