imagecreatefromxpm()函數是PHP中的內置函數,用於從XPM文件或URL創建新圖像。 XPM(X PixMap)是X窗口係統使用的圖像文件格式。可以在程序中進一步處理此加載的圖像。從XPM文件加載圖像後要編輯圖像時,通常使用此函數。可以使用各種在線轉換器將圖像轉換為XPM。
用法:
resource imagecreatefromxpm( string $filename )
參數:該函數接受單個參數$filename,該參數保存圖像的名稱。
返回值:成功時此函數返回圖像資源標識符,錯誤時返回FALSE。
以下示例說明了PHP中的imagecreatefromxpm()函數:
範例1:轉換為PNG後查看XPM。
<?php
// Load an XPM image from local folder
// You can convert any image to XPM using
// Online convertors
$im = imagecreatefromxpm('./geeksforgeeks.xpm');
// Output the image by converting it into PNG
header('Content-type:image/png');
imagepng($im);
imagedestroy($im);
?>
輸出:
範例2:編輯XPM映像。
<?php
// Load an XPM image from local folder
// You can convert any image to XPM using
// online convertors
$im = imagecreatefromxpm('./geeksforgeeks.xpm');
// Apply Green colorise filter
imagefilter($im, IMG_FILTER_COLORIZE, 0, 200, 0);
// Output the image by converting it into PNG
header('Content-type:image/png');
imagepng($im);
imagedestroy($im);
?>
輸出:
參考: https://www.php.net/manual/en/function.imagecreatefromxpm.php
相關用法
- PHP each()用法及代碼示例
- p5.js pow()用法及代碼示例
- p5.js second()用法及代碼示例
- PHP next()用法及代碼示例
- PHP Ds\Set xor()用法及代碼示例
- CSS url()用法及代碼示例
- PHP pow( )用法及代碼示例
- d3.js d3.map.set()用法及代碼示例
- CSS var()用法及代碼示例
- p5.js day()用法及代碼示例
- d3.js d3.set.has()用法及代碼示例
- p5.js hue()用法及代碼示例
注:本文由純淨天空篩選整理自gurrrung大神的英文原創作品 PHP | imagecreatefromxpm() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。