日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
PHP圖片處理庫Grafika詳細(xì)教程(3):圖像屬性處理

該文章是接著上篇文章,《PHP極其強(qiáng)大的圖片處理庫Grafika詳細(xì)教程(2):圖像特效處理模塊》,由于grafika功能太多,所以分開寫,其他的點(diǎn)擊這里

成都創(chuàng)新互聯(lián)公司專注于平原企業(yè)網(wǎng)站建設(shè),響應(yīng)式網(wǎng)站設(shè)計(jì),成都做商城網(wǎng)站。平原網(wǎng)站建設(shè)公司,為平原等地區(qū)提供建站服務(wù)。全流程定制制作,專業(yè)設(shè)計(jì),全程項(xiàng)目跟蹤,成都創(chuàng)新互聯(lián)公司專業(yè)和態(tài)度為您提供的服務(wù)

《1、圖像基本處理》

《2、圖像特效處理模塊》

《3、圖像屬性處理》

《4、圖形繪制》

該文章主要寫grafika的圖像屬性處理功能,共7個(gè)方法。

1、圖片格式化為二進(jìn)制格式輸出

該方法的作用是打開一張圖片,然后格式化為二進(jìn)制數(shù)據(jù),直接輸出到瀏覽器,而不是傳統(tǒng)的src顯示圖片。

其有一個(gè)參數(shù),你可以自定義輸出圖片的格式,比如png啥的

我們這里打開圖片,輸出為png

當(dāng)然你還是要告訴瀏覽器你需要輸出的類型是圖片header('Content-type: image/png');

 
 
  1. use Grafika\Grafika; 
  2. $editor = Grafika::createEditor(); 
  3. $editor->open( $image, 'yanying-smaller.jpg' ); 
  4. header('Content-type: image/png'); // Tell the browser we're sending a png image 
  5. $image->blob('PNG');   

2、獲取圖片當(dāng)前使用的處理庫

使用方法可以獲取處理當(dāng)前圖片,grafika使用了什么庫,是gd還是Imagick

該方法不在editor里面,而是直接在$image里面,沒有任何參數(shù)

 
 
  1. use Grafika\Grafika; 
  2. $editor = Grafika::createEditor(); 
  3. $editor->open( $image, 'yanying-smaller.jpg' ); 
  4. $result = $image->getCore(); 
  5. var_dump($result); // resource(12, gd)  

3、獲取圖片高度

我們圖片高度為213px

 
 
  1. use Grafika\Grafika; 
  2. $editor = Grafika::createEditor(); 
  3. $editor->open( $image, 'yanying-smaller.jpg' ); 
  4. $result = $image->getHeight(); 
  5. var_dump($result); // int 213  

4、獲取圖片寬度

我們圖片寬度為319px

 
 
  1. use Grafika\Grafika; 
  2. $editor = Grafika::createEditor(); 
  3. $editor->open( $image, 'yanying-smaller.jpg' ); 
  4. $result = $image->getWidth(); 
  5. var_dump($result); // int 319  

5、獲取圖片名稱

圖片名稱為當(dāng)前文件名

 
 
  1. use Grafika\Grafika; 
  2. $editor = Grafika::createEditor(); 
  3. $editor->open( $image, 'yanying-smaller.jpg' ); 
  4. $result = $image->getImageFile(); 
  5. var_dump($result); // string 'yanying-smaller.jpg' (length=19)  

6、獲取圖片類型

這里我們發(fā)現(xiàn)是jpg的

 
 
  1. use Grafika\Grafika; 
  2. $editor = Grafika::createEditor(); 
  3. $editor->open( $image, 'yanying-smaller.jpg' ); 
  4. $result = $image->getType(); 
  5. var_dump($result); // string 'JPEG' (length=4)  

7、判斷圖片是否是動(dòng)態(tài)圖片,比如gif

我們這張圖片是jpg的,所以不是動(dòng)態(tài)圖片,返回值為bool類型,true或者false

 
 
  1. use Grafika\Grafika; 
  2. $editor = Grafika::createEditor(); 
  3. $editor->open( $image, 'yanying-smaller.jpg' ); 
  4. $result = $image->isAnimated(); 
  5. var_dump($result); // boolean false  

分享題目:PHP圖片處理庫Grafika詳細(xì)教程(3):圖像屬性處理
文章分享:http://www.5511xx.com/article/coiijeo.html