English | 简体中文 | 繁體中文
查询

jpeg2wbmp()函数—用法及示例

「 将JPEG图像转换为WBMP图像 」


函数名称:jpeg2wbmp()

适用版本:PHP 4 >= 4.0.5, PHP 5, PHP 7

函数描述:将JPEG图像转换为WBMP图像

用法:

bool jpeg2wbmp(string $jpegname, string $wbmpname, int $dest_height, int $dest_width, int $threshold)

参数:

  • $jpegname:JPEG图像文件的路径和文件名。
  • $wbmpname:转换后的WBMP图像文件的路径和文件名。
  • $dest_height:转换后的WBMP图像的高度。
  • $dest_width:转换后的WBMP图像的宽度。
  • $threshold:可选参数,表示用于二值化图像的阈值。默认值为80。

返回值:

  • 如果成功转换并保存了WBMP图像,则返回true。
  • 如果发生错误,则返回false。

示例:

$jpegname = 'path/to/image.jpg';
$wbmpname = 'path/to/image.wbmp';
$dest_height = 200;
$dest_width = 200;
$threshold = 80;

if (jpeg2wbmp($jpegname, $wbmpname, $dest_height, $dest_width, $threshold)) {
    echo 'JPEG image converted to WBMP successfully.';
} else {
    echo 'Failed to convert JPEG image to WBMP.';
}

上述示例将指定的JPEG图像转换为200x200像素的WBMP图像,并将阈值设置为80。如果转换成功,则输出"JPEG image converted to WBMP successfully.",否则输出"Failed to convert JPEG image to WBMP."

补充纠错
下一个函数: join()函数
热门PHP函数
分享链接