zoukankan      html  css  js  c++  java
  • PHP 输出图像 imagegif 、imagejpeg 与 imagepng 函数

    imagegif()、imagejpeg()、imagepng() 和 imagewbmp() 函数分别允许以 GIF、JPEG、PNG 和 WBMP 格式将图像输出到浏览器或文件。

    PHP 输出图像

    PHP 允许将图像以不同格式输出:

    • imagegif():以 GIF 格式将图像输出到浏览器或文件
    • imagejpeg():以 JPEG 格式将图像输出到浏览器或文件
    • imagepng():以 PNG 格式将图像输出到浏览器或文件
    • imagewbmp():以 WBMP 格式将图像输出到浏览器或文件

    语法:

    bool imagegif ( resource image [, string filename] )
    bool imagejpeg ( resource image [, string filename [, int quality]] )
    bool imagepng ( resource image [, string filename] )
    bool imagewbmp ( resource image [, string filename [, int foreground]] )
    
    参数说明:
    参数说明
    image 欲输出的图像资源,如 imagecreate() 或 imagecreatefrom 系列函数的返回值
    filename 可选,指定输出图像的文件名。如果省略,则原始图像流将被直接输出。
    quality 可选,指定图像质量,范围从 0(最差质量,文件最小)到 100(最佳质量,文件最大),默认75 ,imagejpeg() 独有参数
    foreground 可选,指定前景色,默认前景色是黑色,imagewbmp() 独有参数

    绘制一个圆弧并保存到 images 目录下:

    <?php
    header("Content-type: image/png");
    
    $im = @imagecreate(200, 200)or die("创建图像资源失败");
    
    $bg = imagecolorallocate($im, 204, 204, 204);
    $red = imagecolorallocate($im, 255, 0, 0);
    
    imagearc($im, 100, 100, 150, 150, 0, 360, $red);
    
    imagepng($im,"images/circle.png");
    imagedestroy($im);
    ?>
    

    在 images 目录下就会生成一个 circle.png 文件。

  • 相关阅读:
    Golang 版本 支付宝支付SDK app支付接口2.0
    用 Certbot-auto 在 letsencrypt.org申请免费 SSL 证书实现 HTTPS
    Go类型断言demo
    签名算法
    golang cron定时任务简单实现
    Chapter Zero 0.2.2 内存
    Linux-系统目录结构
    Linux-关于Bash
    Chapter Zero 0.2.1 执行运算与判断的CPU
    Chapter Zero 0.1.4 计算机上常用的计算单位
  • 原文地址:https://www.cnblogs.com/tdalcn/p/5899366.html
Copyright © 2011-2022 走看看