douwan4993 2015-07-15 13:45
浏览 48
已采纳

尝试使用PHP在签名图像上呈现头像图像

I am making a dynamic signature generator and I would like to add a avatar image in part of the signature. How would I do this as well as sizing down the image?

  • 写回答

2条回答 默认 最新

  • douyun6781 2015-07-15 17:12
    关注

    Here is an example.

    I have 2 images:

    1. https://s-media-cache-ak0.pinimg.com/736x/d1/2e/9e/d12e9ecd9f4c4e45dafa5880c7d99c73.jpg
    2. http://cf.juggle-images.com/matte/white/280x280/php-1-logo-primary.jpg

    Steps:

    1. Set the content type header - in this case image/jpg
    2. Create new canvas, width: 720, height: 637
    3. Create two new images from file or URL, $icon1 & $icon2
    4. Copy part of $icon1 to $canvas
    5. Copy and resize part of $icon2 to $can
    6. Output image to browser

    <?php
    header('Content-Type: image/jpg');
    $canvas = imagecreatetruecolor(720,  637);
    $icon1 = imagecreatefromjpeg('https://s-media-cache-ak0.pinimg.com/736x/d1/2e/9e/d12e9ecd9f4c4e45dafa5880c7d99c73.jpg');
    $icon2 = imagecreatefromjpeg('http://cf.juggle-images.com/matte/white/280x280/php-1-logo-primary.jpg');
    
    //add 2 source images
    imagecopy($canvas, $icon1, 0, 0, 0, 0, 720,  637);
    imagecopyresized($canvas, $icon2, 0, 0, 0, 0, 100, 100, 280, 280);
    
    //Output image to browser
    imagejpeg($canvas);
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用