签名图片拼接

<?php
header("Content-type: text/html; charset=utf-8");$res = new createIng();
$filename = "123" . '.jpg';$reply = array();
$reply['font1'] = 905;
$reply['font2'] = 905;
$reply['reply7'] = "你也来生成一个试试看";
$reply['ewm'] = "[\"./ewm.jpg\",\"./ewm.jpg\",\"./ewm.jpg\"]";$res->createImg($reply,"刘腾",1);/*
for ($x=0; $x<=110; $x++) {$res->createImg($reply,$x.".png","马化腾",1);
}*/
echo 222;class createIng
{public function createImg($reply,  $name, $count){if ($count == 1) {$type = $reply['font1'];} elseif ($count == 2) {$type = $reply['font2'];}//id1:字体类型(905为一笔商务签名)  id2签名背景  id4:签名配色  id6 签名颜色$post_data = array('id' => $name, 'id1607' => '', 'id1609' => 'jiqie', 'id1608' => 'jiqie_com', 'id1' => 2, 'id2' => '#fce7c0', 'id3' => '', 'id4' => '#FFFFFF', 'idi' => 'jiqie', 'id5' => '', 'id6' => '#000000');// $post_data = array('id' => $name, 'id1607' => '', 'id1609' => 'jiqie', 'id1608' => 'jiqie_com', 'id1' => $type, 'id2' => '#fce7c0', 'id3' => '', 'id4' => '#FFFFFF', 'idi' => 'jiqie', 'id5' => '', 'id6' => '#000000');//加请求头$header=array('Accept-Language:zh-CN','x-appkey:114816004000028','x-apsignature:933931F9124593865313864503D477035C0F6A0C551804320036A2A1C5DF38297C9A4D30BB1714EC53214BD92112FB31B4A6FAB466EEF245710CC83D840D410A7592D262B09D0A5D0FE3A2295A81F32D4C75EBD65FA846004A42248B096EDE2FEE84EDEBEBEC321C237D99483AB51235FCB900AD501C07A9CAD2F415C36DED82','x-apversion:1.0','Content-Type:application/x-www-form-urlencoded','charset:utf-8','Accept:application/json','X-APFormat:json');//获取图片$res = $this->tocurl('http://www.yishuzi.com/b/re13.php',$header,$post_data);//$res = $this->tocurl('http://www.yishuzi.com/a/re.php',$header,$post_data);$reg = '/<img (.*?)+src=[\'"](.*?)[\'"]/i';preg_match_all( $reg , $res , $results );//打印出来// print_r($results[2][0]);die;//把整个文件读入一个字符串$content = file_get_contents($results[2][0]);$src_im = imagecreatefromstring($content);//创建一个画布$im = imagecreate(480, 350);//默认颜色是黑色,设置为透明$white = imagecolorallocate($im, 0,0,0);//给$im画布添加属性imagecolortransparent($im, $white);//二维码大小$newwidth = 120;$newheight = 120;if (!empty($reply['ewm'])) {$ewms = json_decode($reply['ewm'],true);if (empty($reply['ewm'])) {$ewm = $reply['ewm'];} else {shuffle($ewms);$ewm = $ewms[0];}}$src_im1 = imagecreatefromstring(file_get_contents($ewm));//创建的是一幅大小为 x和 y的图像(默认为黑色)$dst_im = imagecreatetruecolor($newwidth, $newheight);// 新建一个真彩色图像$color = imagecolorallocate($dst_im, 255, 255, 255);//将$dst_im图像中的透明色设定为 $colorimagecolortransparent($dst_im, $color);//imagefill() 在 image 图像的坐标 x,y(图像左上角为 0, 0)处用 color 颜色执行区域填充(即与 x, y 点颜色相同且相邻的点都会被填充imagefill($dst_im, 0, 0, $color);//imagecopyresized() 函数用于拷贝图像或图像的一部分并调整大小(生成缩略图),成功返回 TRUE,否则返回 FALSE。@imagecopyresized($dst_im, $src_im1, 0, 0, 0, 0, $newwidth, $newheight, imagesx($src_im1), imagesy($src_im1));//函数用于拷贝并合并图像的一部分(调整二维码的距离)imagecopymerge($im, $dst_im, 20, 220, 0, 0, $newwidth, $newheight, 100);//签名图与背景图合并$path_1 = "./bjImg.jpg";$image_1 = imagecreatefromjpeg($path_1);$image_3 = imageCreatetruecolor(imagesx($image_1),imagesy($image_1));$color = imagecolorallocate($image_3, 255, 255, 255);imagefill($image_3, 0, 0, $color);imageColorTransparent($image_3, $color);imagecopyresampled($image_3,$image_1,0,0,0,0,imagesx($image_1),imagesy($image_1),imagesx($image_1),imagesy($image_1));imagecopymerge($image_3,$im, 0,0,0,0,imagesx($im),imagesy($im), 100);//加字体$stra = "姓名:" . $name;$black = imagecolorallocate($image_3, 0, 0, 0);imagettftext($image_3, 13, 0, 150, 293, $black, dirname(preg_replace('@\(.*\(.*$@', '', __FILE__)) . "/simkai1.ttf", $stra);imagecopy($image_3, $src_im, 32, 10, 30, 39, 420, 204);$str = $reply['reply7'];imagettftext($image_3, 14, 0, 150, 325, $black, dirname(preg_replace('@\(.*\(.*$@', '', __FILE__)) . "/simkai1.ttf", $str);//将画布保存到指定的gif文件imagejpeg($image_3, "./hero_gam.jpg");header("Content-type: image/jpeg");imagejpeg($image_3);exit();//压缩文件并保存在文件/*  imagejpeg($im, dirname(__FILE__) . $filename);header("Content-type: image/jpeg");imagejpeg($im);*/}function send_post($url, $post_data){$postdata = http_build_query($post_data);$options = array('http' => array('method' => 'POST', 'header' => 'Content-type:application/x-www-form-urlencoded', 'content' => $postdata, 'timeout' => 60));$context = stream_context_create($options);$result = file_get_contents($url, false, $context);return $result;}/*** 发送数据* @param String $url     请求的地址* @param Array  $header  自定义的header数据* @param Array  $content POST的数据* @return String*/public  function tocurl($url, $header,$post_data){$ch = curl_init();if(substr($url,0,5)=='https'){curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, true);  // 从证书中检查SSL加密算法是否存在}curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);curl_setopt($ch, CURLOPT_URL, $url);curl_setopt($ch, CURLOPT_HTTPHEADER, $header);curl_setopt($ch, CURLOPT_POST, true);curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_data));$response = curl_exec($ch);if($error=curl_error($ch)){die($error);}curl_close($ch);//var_dump($response);return $response;}}

拼接主要代码:

//签名图与背景图合并$path_1 = "./bjImg.jpg";$image_1 = imagecreatefromjpeg($path_1);$image_3 = imageCreatetruecolor(imagesx($image_1),imagesy($image_1));$color = imagecolorallocate($image_3, 255, 255, 255);imagefill($image_3, 0, 0, $color);imageColorTransparent($image_3, $color);imagecopyresampled($image_3,$image_1,0,0,0,0,imagesx($image_1),imagesy($image_1),imagesx($image_1),imagesy($image_1));imagecopymerge($image_3,$im, 0,0,0,0,imagesx($im),imagesy($im), 100);

PHP图片拼接util相关推荐

  1. c#图像处理、图片拼接、图片裁剪、图片缩放、图上添加形状、屏幕截图、图片反色、改变图片色彩度全解

    全栈工程师开发手册 (作者:栾鹏) c#教程全解 using System; using System.Collections.Generic; using System.ComponentModel ...

  2. 纯java处理图片拼接(背景上边添加文字和图片)

    好消息,百度网盘专业搜索网站上线了 打开瞧一瞧:[url]http://bitar.cn[/url] package com.pic; import java.awt.Color;import jav ...

  3. 很强大的java图片拼接工具类,可用于各种图片创建、图片生成、图文拼接、藏宝图分块拼接、分享海报

    ImgJoinUtil图片拼接工具类 import com.sun.image.codec.jpeg.JPEGCodec; import com.sun.image.codec.jpeg.JPEGIm ...

  4. java 图片流 拼接_java 实现图片拼接

    importjavax.imageio.ImageIO;importjava.awt.image.BufferedImage;importjava.io.File;importjava.util.Ar ...

  5. java 实现图片拼接

    1.想要实现多个图片的纵向和横向拼接.实现代码如下 2.补充发现横向拼接的一个bug 宽度没有增加(已修复) 百度地址:工具jar下载 链接:https://pan.baidu.com/s/1uZCN ...

  6. Android报错:java.lang.NoClassDefFoundError: Failed resolution of: Ljava/util/Base64;如何解决

    原因是使用了java标准库里的java.util.Base64这个类,编译时不会报错,但运行时直接崩溃了. 解决方法是用android自带的Base64类替换,直接import android.uti ...

  7. java vector search_java.util.Vector.retainAll()方法实例

    全屏 retainAll(Collection> c)方法用于仅保留此向量包含在指定Collection的元素.换言之,删除这个向量的所有元素未包含在指定Collection. 声明 以下是ja ...

  8. android.util.AndroidRuntimeException: requestFeature() must be called before adding content

    问题 Caused by: android.util.AndroidRuntimeException: requestFeature() must be called before adding co ...

  9. Error: module pages/utils/util is not defined

    错误如下: 处理方法是两个../上再加一个../ 自己之前写的会报错,const util = require('../../utils/util') 修改之后:const util = requir ...

最新文章

  1. ios 标准 #pragma mark的用法
  2. 常用Apache Commons工具类备忘
  3. 3-5Tensor创建编程实例
  4. 机械师开机黑屏自动修复此计算机,机械师F117-V-BISO还原教程
  5. 【Elasticsearch】es 报错 index has not yet rolled over with that alias
  6. python 切片函数,python切片详解
  7. 【Lucene】Apache Lucene全文检索引擎架构之中文分词和高亮显示4
  8. linux qt自带例子无法,在Qt Creator中,错过了一些例子
  9. 2019 PC 台式机垃圾佬 记录
  10. [EMQX-V3.4.6源码解析系列]-1-EMQX简介
  11. hp打印机没有右键扫描_win10打印机右键没有‘开始扫描’的修复办法
  12. C4996 scanf:This function or variable may be unsafe. / C6031 返回值被忽略.
  13. 11个资源强大的网站!知乎超20万人强烈推荐,再也不怕资源难找
  14. 【经验分享】怎么催审稿意见、催稿信例文
  15. 线性回归模型的公式推导
  16. 配电站智能巡检机器人,电力智能巡检机器人
  17. 百度IFE前端学院-DAY1-Web开发概览
  18. 华硕z170a如何开启m2_华硕Z170主板bios如何设置|华硕Z170主板设置bios的方法
  19. 【亲测有效】解决执行nrm ls命令查看不到*星号的问题
  20. TiDB 在海航易建科技与香港航空研发收益支持系统过程中的实践

热门文章

  1. 两万元的计算机什么配置,两万高配置电脑使用CAD非常卡顿怎么办
  2. 深度相机(八)--OpenNI及与Kinect for windows SDK的比较
  3. 今日早报 每天一分钟知晓天下事 3-13
  4. 记2017第八届蓝桥杯决赛(国赛)—北京三日游
  5. 响铃:360浏览器首创自有根证书,不赚钱为哪般?
  6. 使用云祺虚拟机备份软件备份H3C CAS 虚拟机
  7. 【自然语言处理】BERT GPT
  8. android 画图一
  9. Laravel 5 - Trait method can has not been applied, because there are collisions with other trai
  10. 电子招投标智能辅助评标系统,有哪些实施成效?