溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

PHP中Grafika如何實現圖像屬性處理

發布時間:2021-11-02 11:41:08 來源:億速云 閱讀:150 作者:小新 欄目:編程語言

這篇文章主要為大家展示了“PHP中Grafika如何實現圖像屬性處理”,內容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領大家一起研究并學習一下“PHP中Grafika如何實現圖像屬性處理”這篇文章吧。

1、圖片格式化為二進制格式輸出

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

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

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

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

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

PHP中Grafika如何實現圖像屬性處理

2、獲取圖片當前使用的處理庫

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

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

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

3、獲取圖片高度

我們圖片高度為213px

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

4、獲取圖片寬度

我們圖片寬度為319px

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

5、獲取圖片名稱

圖片名稱為當前文件名

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

6、獲取圖片類型

這里我們發現是jpg的

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

7、判斷圖片是否是動態圖片,比如gif

我們這張圖片是jpg的,所以不是動態圖片,返回值為bool類型,true或者false

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

以上是“PHP中Grafika如何實現圖像屬性處理”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注億速云行業資訊頻道!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

php
AI

亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女