• PHP实现装B神器简单实现案例(一)


    就实现上图效果,php操作图片的案例简单实现

    $name = "哇哈哈";
    $namea = "计算机应用管理";
    $nameb = "软件开发";
    //新建一个真彩色图像 -- imagecreatetruecolor(int $width , int $height)
    $im = imagecreatetruecolor(800, 500);
    //由文件或 URL 创建一个新图象 -- imagecreatefromjpeg(string $filename)
    $bg = imagecreatefromjpeg('toutu.jpg');
    
    //拷贝图像的一部分 -- imagecopy(resource $dst_im , resource $src_im , int $dst_x , int $dst_y , int $src_x , int $src_y , int $src_w , int $src_h)
    //将 src_im 图像中坐标从 src_x,src_y 开始,宽度为 src_w,高度为 src_h 的一部分拷贝到 dst_im 图像中坐标为 dst_x 和 dst_y 的位置上。
    imagecopy($im,$bg,0,0,0,0,900,539);
    //imagedestroy — 销毁一图像
    imagedestroy($bg);
    //为一幅图像分配颜色 -- imagecolorallocate( resource $image , int $red , int $green , int $blue)
    $black = imagecolorallocate($im, 60, 60, 60);
    $font = 'fh.ttf';
    $blacka = imagecolorallocate($im, 0, 0, 0);
    //用TrueType字体向图像写入文本 -- imagettftext(resource $image , float $size , float $angle , int $x , int $y , int $color , string $fontfile , string $text)
    //image--由图象创建函数返回的图象资源。
    //size--字体的尺寸
    //angle--角度制表示的角度,0 度为从左向右读的文本
    //x由 x,y 所表示的坐标定义了第一个字符的基本点(大概是字符的左下角)
    //y Y 坐标。它设定了字体基线的位置,不是字符的最底端。
    //color 颜色索引。使用负的颜色索引值具有关闭防锯齿的效果
    //fontfile 是想要使用的 TrueType 字体的路径。
    imagettftext($im, 14, 0, 285, 217, $blacka, $font, $name);
    imagettftext($im, 14, 0, 485, 250, $blacka, $font, $namea);
    imagettftext($im, 14, 0, 391, 280, $blacka, $font, $nameb);
    
    // 输出图像
    header("Content-type: image/png");
    imagejpeg($im);
  • 相关阅读:
    Linux下find命令详解
    shell if语句
    目标文件系统映像制作工具mkyaffs2image
    编译内核
    FPS含义
    linux下echo命令详解
    Mssql数据库语句综合
    string 字符串操作
    Lession 15 Good news
    Mysql使作心得(备份,还原,乱码处理)
  • 原文地址:https://www.cnblogs.com/yeshaoxiang/p/7839333.html
Copyright © 2020-2023  润新知