• 首页
  • vue
  • TypeScript
  • JavaScript
  • scss
  • css3
  • html5
  • php
  • MySQL
  • redis
  • jQuery
  • imagexbm()

    (PHP 5, PHP 7)

    将 XBM 图像输出到浏览器或文件

    说明

    imagexbm(resource $image,string $filename[,int $foreground]): bool

    将XBM图像$image输出到浏览器或文件

    参数

    $image

    由图象创建函数(例如imagecreatetruecolor())返回的图象资源。

    $filename

    文件保存的路径,如果未设置或为NULL,将会直接输出原始图象流。

    $foreground

    你可以从imagecolorallocate()分配一个颜色,并设置为该前景色参数。默认颜色是黑色。

    返回值

    成功时返回TRUE,或者在失败时返回FALSE

    范例

    保存一个 XBM 文件

    <?php
    // 创建空白图像并添加文字
    $im = imagecreatetruecolor(120, 20);
    $text_color = imagecolorallocate($im, 233, 14, 91);
    imagestring($im, 1, 5, 5,  'A Simple Text String', $text_color);
    // 保存图像
    imagexbm($im, 'simpletext.xbm');
    // 释放内存
    imagedestroy($im);
    ?>
    

    以不同前景色保存一个 XBM 文件

    <?php
    // 创建空白图像并添加文字
    $im = imagecreatetruecolor(120, 20);
    $text_color = imagecolorallocate($im, 233, 14, 91);
    imagestring($im, 1, 5, 5,  'A Simple Text String', $text_color);
    // 设置替换的前景色
    $foreground_color = imagecolorallocate($im, 255, 0, 0);
    // 保存图像
    imagexbm($im, NULL, $foreground_color);
    // 释放内存
    imagedestroy($im);
    ?>
    

    注释

    Note:此函数仅在与 GD 库捆绑编译的 PHP 版本中可用。

    上篇:imagewebp()

    下篇:iptcembed()