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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。