imagexbm()函数是PHP中的内置函数,用于显示图像以浏览文件。此函数的主要用途是在浏览器中查看图像并将任何其他图像类型转换为XBM。
用法:
bool imagexbm( resource $image, int $to, int $foreground)
参数:此函数接受上述和以下所述的三个参数:
- $image:它指定要处理的图像资源。
- $to (Optional):它指定将文件保存到的路径。
- $foreground (Optional):它指定图像的前景。
返回值:如果成功,此函数将返回TRUE,否则将返回FALSE。
以下示例说明了PHP中的imagexbm()函数:
范例1:在此示例中,我们将在浏览器中下载图像。
<?php
// Load an xbm image from local folder
// Image can be converted into xbm using
// online convertors or imagexbm()
$im = imagecreatefromxbm('geeksforgeeks.xbm');
// Download the image
header('Content-Type:image/xbm');
imagexbm($im);
imagedestroy($im);
?>
输出:
This will download your image as download, further you can rename this file to anything like geeksforgeeks.xbm and use it.
范例2:在此示例中,我们将PNG转换为XBM。
<?php
// Load an image from PNG URL
$im = imagecreatefrompng(
'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png');
// Convert the image into XBM using imagexbm() function
imagexbm($im, 'converted.xbm');
imagedestroy($im);
?>
输出:
This will save the XBM version of image in the same folder where your PHP script is.
参考: https://www.php.net/manual/en/function.imagexbm.php
相关用法
- p5.js min()用法及代码示例
- PHP Ds\Set get()用法及代码示例
- p5.js hue()用法及代码示例
- PHP pow( )用法及代码示例
- PHP next()用法及代码示例
- p5.js value()用法及代码示例
- d3.js d3.map.set()用法及代码示例
- d3.js d3.max()用法及代码示例
- d3.js d3.min()用法及代码示例
- d3.js d3.mean()用法及代码示例
- p5.js tan()用法及代码示例
- p5.js sin()用法及代码示例
注:本文由纯净天空筛选整理自gurrrung大神的英文原创作品 PHP | imagexbm() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。