如何在PHP中使用imagecreatefromwbmp()函数从WBMP文件或URL创建一个新图像?


在PHP中,**imagecreatefromwbmp()** 是一个内置函数,用于从WBMP文件或URL创建一个新图像。**imagecreatefromwbmp()** 返回一个图像标识符,表示从给定文件名获得的图像。 当我们想要在从WBMP文件加载图像后编辑它们时,可以使用**imagecreatefromwbmp()**。使用imagewbmp()函数,可以将图像转换为WBMP格式。

语法

resource imagecreatefromwbmp(string $filename)

参数

**imagecreatefromwbmp()** 只接受一个参数,**$filename**。它包含图像的文件名。

返回值

**imagecreatefromwbmp()** 成功时返回一个图像资源标识符,失败时返回错误。

示例1

<?php
   // Loading the WBMP image from the local drive folder
   $img = imagecreatefromwbmp'C:\xampp\htdocs\pic.wbmp');
   // View the loaded image in the browser
   imagewbmp($img);
   imagedestroy($img);
?>

输出

Note − The above PHP code will load the content into the browser in the unsupported form text as browsers don't support WBMP.

示例2

<?php
   // Load a WBMP image from the local drive folder
   //We can convert the image to WBMP using the online converter
   //or using the imagewbmp() function
   $img = imagecreatefromwbmp('C:\xampp\htdocs\Images\img30.wbmp');
   
   // Save the GIF image into the given local drive folder path.
   imagejpeg($img,'C:\xampp\htdocs\pic.gif');
   imagedestroy($img);
?>

使用imagecreatefromwbmp()函数之前的原始输入图像

使用imagecreatefromwbmp()函数后的输出图像

注意 − WBMP是无线位图文件格式。它是一种针对移动计算设备优化的WAP图形格式。WBMP格式的图片以位图格式保存。也就是说,图像的每个像素都保存为1位。要打开WBMP文件,需要无线位图文件格式软件。

更新于:2021年8月9日

198 次浏览

启动你的职业生涯

完成课程获得认证

开始学习
广告
© . All rights reserved.