推销部门的海报,大致类容都差不多,经常会修改一些简介,诊疗范围,擅长病种等等,刚开始想到的是利用扩展截图然后去下载,网上的例子倒是不多,目前有两个例子

  1. zyan/url2pic-sdk
    CSDN地址
    可以composer安装,也可调用接口
    composer安装的时候有冲突,捣鼓了一阵发现需要安装一些别的扩展,就放弃,不想安装太多扩展
    就开始调用API 但是返回来的图片好多css都没加载完就截图完成了,他应该是网站加载完就截图了,没有等适配就截图了,所以布局的时候需要考虑进去
  2. PhantomJS
    这个也是composer安装的时候需要额外安装一些扩展,实用性有待参考

后来才想起来海报图,之前一直就想的是生成网页,然后截图,下载就行。
下面是原图

正如图片所示,需要修改的地方还蛮多的,名称的位置,名称可能两位数,三位数,四位数,也需要判断去调整left的位置,名称下的标签也是一样,根据字数调整文字的大小等等,还有成就需要去掉标签载换行,然后添加上对应的五角星。后台:简介这里做了一个开关,打开的时候必须填写简介内容,下方的诊疗范围/擅长范围,有两个板块,只能显示一个,所以做了一个开关控制,单选选择这两个小板块,
简介这里由于文字不定,所以稍微计算了一下文字的高度,来自适应的增加/减去背景的高度,下方的诊疗范围也是一样
代码垃圾,后期会优化

 protected $summary_height = ''; // 简介范围文字的高度protected $dat_height = ''; // 诊疗范围文字的高度protected $good_at_height = ''; // 擅长范围文字的高度protected $brown_height = 1500; // 下半部分 棕色部分“一行文字”所需最低高度protected $Pentagram = ''; // 五角星protected $textRows = ''; // 文字行数protected $textRowsHight = 0; // 文字行数 高protected $bat_ga_textRows = ''; // 诊疗/擅长行数protected $bat_ga_image_top = 0; // 诊疗/擅长 上半部分protected $bat_ga_image_down = 65; // 诊疗/擅长 下半部分 背景高度/*** 生成海报图* @param $docname // 医生名称* @param $doclabel    // 医生职称* @param $docimg   // 医生图片* @param $docachieve   // 医生成就* @param $syswitch // 简介开关* @param $summary  // 简介内容* @param $gaswitch // 诊疗/擅长开关* @param $gadata  // 诊疗/擅长 选择* @param $gac      // 诊疗/擅长内容*/public function posterImage($docname,$doclabel,$docimg,$docachieve,$syswitch = 0,$summary,$gaswitch = 0,$gadata = 0,$gac){$summary = $this->tagecontent($summary,mb_strlen($summary,"utf-8"));$gac = $this->tagecontent($gac,mb_strlen($gac,"utf-8"));// 转换 成就 值// 正则匹配获取p标签里的值,并重新赋值$matches = '';// preg_match 匹配出第一条符合条件的数据后停止继续操作// preg_match_all 匹配出全部preg_match_all('/<p.*?>(.*?)(?=<\/p>)/im', $docachieve, $matches);unset($matches[0]);foreach($matches[1] as $v){$search = array(" "," ","\t","\n","\r");$v = str_replace($search, '', $v);$val = trim(strip_tags($v));if(!empty($val)){$bt_arrays[] = $val;}}// 过滤数组中的元素。$bt_arrays = array_filter($bt_arrays);// 数组转字符串并换行$docachieve = implode("\n",$bt_arrays);// 统计五角星$this->Pentagram = count($bt_arrays);// 获得职位长度,调整位置$length_label = mb_strlen($doclabel,"utf-8");$label_left = 100;$label_fontSize = 35;switch ($length_label){case $length_label == 4;$label_left = 150;break;case $length_label == 5;$label_left = 120;break;case $length_label == 6;$label_left = 95;break;case $length_label == 7;$label_left = 70;break;case $length_label == 8;$label_left = 50;break;case $length_label == 9;$label_left = 38;$label_fontSize = 33;break;case $length_label == 10;$label_left = 39;$label_fontSize = 29;break;case $length_label == 11;$label_left = 39;$label_fontSize = 27;break;default:$label_left = 100;};// 字体文件,可以去百度下载,计算机里面也有,可以复制到项目里去用,路径要用绝对路径$fontPath = ROOT_PATH.'/public/assets/fonts/5c8a05a7b3b641552549287.otf';$config = ['text' => [[// 医生名称'text'      => $docname,'left'      => 55,                //文字距离左边框多远(负数是从右往左)'top'       => 600,               //文字距离上边框多远(负数是从下往上)'fontPath'  => $fontPath,       //字体文件'fontSize'  => 90,              //字号'fontColor' => '115,66,34',     //字体颜色'angle'     => 0,             //倾斜角度'spacing'   => 25,              //字间距调整设置],[// 医生标签'text'      => $doclabel,'left'      => $label_left,             //文字距离左边框多远(负数是从右往左)'top'       => 700,           //文字距离上边框多远(负数是从下往上)'fontPath'  => $fontPath,       //字体文件'fontSize'  => $label_fontSize,              //字号'fontColor' => '255,255,255',      //字体颜色'angle'     => 0,             //倾斜角度],],'achieve' =>[// 医生成就'text'      => $docachieve,'left'      => 62,               //文字距离左边框多远(负数是从右往左)'top'       => 720,           //文字距离上边框多远(负数是从下往上)'fontPath'  => $fontPath,     //字体文件'fontSize'  => 23,              //字号'fontColor' => '0,0,0',     //字体颜色'angle'     => 0,               //倾斜角度'width'     => 500,],'image' => [[//海报上部分图'url'       => "../public/assets/XXXX/13_01.png", //图片地址'stream'    => 0,//图片资源是否是字符串图像流'left'      => 0,//图片距离左边框多远(负数是从右往左)'top'       => 0    ,//图片距离上边框多远(负数是从下往上)'right'     => 0,'bottom'    => 0,'width'     => 950,//图片宽度(不要超过背景图的尺寸)'height'    => 1063,//图片高度(不要超过背景图的尺寸)'opacity'   => 100,//透明度'radius'    => 0,//图片圆角角度],[// 医生图片'url'       => ROOT_PATH.'/public/'.$docimg,'stream'    => 0,'left'      => 520,'top'       => 123,'right'     => 0,'bottom'    => 0,'width'     => 430,'height'    => 940,'opacity'   => 100,'radius'    => 15,],[// 底部'url'       => "../public/assets/XXXX/17_02.png",'stream'    => 0,'left'      => 0,'top'       => -1,'right'     => 0,'bottom'    => 0,'width'     => 950,'height'    => 290,'opacity'   => 100,],],'background'    => '../public/assets/XXXX/14.png', //背景图'pentagram'     => ['url'       => '../public/assets/XXXX/wujiaoxing.png', // 五角星'stream'    => 0,'left'      => 35,'top'       => 748,'right'     => 0,'bottom'    => 0,'width'     => 25,'height'    => 25,'opacity'   => 100,],];if($syswitch == 1){$sy_title_img = [// 医生简介头部'url'       => "../public/assets/XXXX/18_02.png",'stream'    => 0,'left'      => 0,'top'       => 1090,'right'     => 0,'bottom'    => 0,'width'     => 950,'height'    => 52,'opacity'   => 100,'radius'    => 15,];$sy_text = [// 简介'text' => $this->getbrtext(1060, 22, 0, $fontPath, $summary,1), // 文字换行'left' => 40,                //文字距离左边框多远(负数是从右往左)'top' => 1190,            //文字距离上边框多远(负数是从下往上)'fontPath' => $fontPath,        //字体文件'fontSize' => 18,                //字号'fontColor' => '255,255,255',        //字体颜色'angle' => 0,                //倾斜角度];array_push($config['image'],$sy_title_img);array_push($config['text'],$sy_text);// 背景最低高度 + 文字高度$this->brown_height =  $this->brown_height + $this->summary_height;if ($gaswitch == 1){// 诊疗/擅长 头部 距离简介文字的高度$this->bat_ga_image_top = 1190 + $this->summary_height + $this->textRows;$in_text = [// 擅长'text' => $this->getbrtext(990, 22, 0, $fontPath, $gac,2), // 文字换行'left' => 80,                //文字距离左边框多远(负数是从右往左)'top' => $this->bat_ga_image_top + 105,//文字距离上边框多远(负数是从下往上)105是富裕高度'fontPath' => $fontPath,        //字体文件'fontSize' => 18,                //字号'fontColor' => '98,98,98',        //字体颜色'angle' => 0,                //倾斜角度];array_push($config['text'],$in_text);// 诊疗信息下半部分$in_image_down =[// 诊疗/擅长 信息下半部分'url'       => "../public/assets/XXXX/121_03.png",'stream'    => 0,'left'      => 0,'top'       => $this->bat_ga_image_top + 50,// 50是富裕高度'right'     => 0,'bottom'    => 0,'width'     => 950,'height'    => 65,'opacity'   => 100,'radius'    => 15,];if ($gadata == 1){// 默认的高度是 65$in_dat = [// 诊疗信息头部'url'       => "../public/assets/XXXX/13_02.png",'stream'    => 0,'left'      => 0,'top'       => $this->bat_ga_image_top,'right'     => 0,'bottom'    => 0,'width'     => 950,'height'    => 52,'opacity'   => 100,'radius'    => 15,];// 背景图片的高 加上文字的高度 加上20 的富裕高度$in_image_down['height'] = 65 + $this->dat_height + 20;$this->bat_ga_image_down = $in_image_down['height'];array_push($config['image'],$in_dat);}else{$in_ga = [// 擅长信息头部'url'       => "../public/assets/XXXX/14_02.jpg",'stream'    => 0,'left'      => 0,'top'       => $this->bat_ga_image_top,'right'     => 0,'bottom'    => 0,'width'     => 950,'height'    => 52,'opacity'   => 100,'radius'    => 15,];// 背景图片的高 加上文字的高度 加上20 的富裕高度$in_image_down['height'] = 65 + $this->dat_height + 20;$this->bat_ga_image_down = $in_image_down['height'];array_push($config['image'],$in_ga);// 擅长信息头部图片不规整 调整一下$in_image_down['left'] = 2;}array_push($config['image'],$in_image_down);$this->brown_height = $this->brown_height + $this->bat_ga_image_down + 50;}}else{if ($gaswitch == 1){// 诊疗/擅长 头部 距离简介文字的高度$in_text = [// 擅长'text' => $this->getbrtext(990, 22, 0, $fontPath, $gac,2), // 文字换行'left' => 80,                //文字距离左边框多远(负数是从右往左)'top' => 1090 + 105,            //文字距离上边框多远(负数是从下往上)'fontPath' => $fontPath,        //字体文件'fontSize' => 18,                //字号'fontColor' => '98,98,98',        //字体颜色'angle' => 0,                //倾斜角度];array_push($config['text'],$in_text);// 诊疗信息下半部分 默认的高度是 $bat_ga_image_down 316$in_image_down =[// 诊疗/擅长 信息下半部分'url'       => "../public/assets/XXXX/121_03.png",'stream'    => 0,'left'      => 0,'top'       => 1090 + 50,'right'     => 0,'bottom'    => 0,'width'     => 950,'height'    => 65,'opacity'   => 100,'radius'    => 15,];if ($gadata == 1){// 默认的高度是 65$in_dat = [// 诊疗信息头部'url'       => "../public/assets/XXXX/13_02.png",'stream'    => 0,'left'      => 0,'top'       => 1090,'right'     => 0,'bottom'    => 0,'width'     => 950,'height'    => 52,'opacity'   => 100,'radius'    => 15,];// 背景图片的高 加上文字的高度 加上20 的富裕高度$in_image_down['height'] = 65 + $this->dat_height + 20;$this->bat_ga_image_down = $in_image_down['height'];$this->brown_height = $this->brown_height + $this->dat_height + 50;array_push($config['image'],$in_dat);}else{$in_ga = [// 擅长信息头部'url'       => "../public/assets/XXXX/14_02.jpg",'stream'    => 0,'left'      => 0,'top'       => 1090,'right'     => 0,'bottom'    => 0,'width'     => 950,'height'    => 52,'opacity'   => 100,'radius'    => 15,];// 背景图片的高 加上文字的高度 加上20 的富裕高度$in_image_down['height'] = 65 + $this->dat_height + 20;$this->bat_ga_image_down = $in_image_down['height'];$this->brown_height = $this->brown_height + $this->dat_height + 50;array_push($config['image'],$in_ga);// 图片不规整 调整一下$in_image_down['left'] = 2;}array_push($config['image'],$in_image_down);}}$filename = '/promote/'.time().'.jpg';$file_path = ROOT_PATH.'/public'.$filename;$file_dir = 'promote/';// 判断是否有这个文件夹  没有的话就创建一个if(!is_dir($file_dir)){// 创建文件夹mkdir($file_dir);}// 这里调用上面生成海报的根方法,将组装的参数和设置的图片名称传过去$url = $this->createPoster($config,$file_path,$syswitch,$gaswitch,$gadata);// 这里会直接输出海报图,在调试的时候开启使用
//        echo "<img src='".$filename."'>";return $filename;}

生成海报图

/*** 生成宣传海报* @param array  参数,包括图片和文字* @param string  $filename 生成海报文件名,不传此参数则不生成文件,直接输出图片* @return [type] [description]*/public function createPoster($config=[],$filename="",$syswitch,$gaswitch,$gadata){//如果要看报什么错,可以先注释调这个headerif(empty($filename)) header("content-type: image/png");$imageDefault = array('left'=>0,'top'=>0,'right'=>0,'bottom'=>0,'width'=>100,'height'=>100,'opacity'=>100);$textDefault = array('text'=>'','left'=>0,'top'=>0,'fontSize'=>32,       //字号'fontColor'=>'255,255,255', //字体颜色'angle'=>0,);$background = $config['background'];//海报最底层得背景// 背景方法// getimagesize() 函数用于获取图像大小及相关信息,成功返回一个数组,失败则返回 FALSE 并产生一条 E_WARNING 级的错误信息。$backgroundInfo = getimagesize($background);//  根据指定的图像类型返回对应的后缀名。$backgroundFun = 'imagecreatefrom'.image_type_to_extension($backgroundInfo[2], false);$background = $backgroundFun($background);$backgroundWidth = imagesx($background);  // 返回原图背景宽度$backgroundHeight = imagesy($background);  // 返回原图背景高度if ($syswitch == 1){$backgroundHeight = $this->brown_height;}else{if ($gaswitch == 1){if ($gadata == 1){$backgroundHeight = $this->brown_height;}else{$backgroundHeight = $this->brown_height;}}}// PHP中的内置函数,用于创建新的true-color图像。此函数返回给定尺寸的空白图像。$imageRes = imageCreatetruecolor($backgroundWidth,$backgroundHeight);// PHP中的内置函数,用于设置图像的颜色。此函数返回以RGB格式给出的颜色。$color = imagecolorallocate($imageRes, 0, 0, 0);// PHP中的内置函数,用于用给定的颜色填充图像。此函数以给定的坐标(图像的左上角为0、0)开始执行填充。imagefill($imageRes, 0, 0, $color);// imageColorTransparent($imageRes, $color);  //颜色透明// 通过重采样复制和调整图像的一部分
imagecopyresampled($imageRes,$background,0,0,0,0,imagesx($background),imagesy($background),imagesx($background),imagesy($background));//处理了图片if(!empty($config['image'])){foreach ($config['image'] as $key => $val) {$val = array_merge($imageDefault,$val);$info = getimagesize($val['url']);// 根据指定的图像类型返回对应的后缀名。$function = 'imagecreatefrom'.image_type_to_extension($info[2], false);if($val['stream']){   //如果传的是字符串图像流// 从字符串中获取图像尺寸信息。$info = getimagesizefromstring($val['url']);// imagecreatefromstring 从字符串中的图像流新建一图像$function = 'imagecreatefromstring';}$res = $function($val['url']);$resWidth = $info[0];$resHeight = $info[1];//建立画板 ,缩放图片至指定尺寸// PHP中的内置函数,用于创建新的true-color图像。此函数返回给定尺寸的空白图像。$canvas = imagecreatetruecolor($val['width'], $val['height']);imagefill($canvas, 0, 0, $color);// 关键函数,参数(目标资源,源,目标资源的开始坐标x,y, 源资源的开始坐标x,y,目标资源的宽高w,h,源资源的宽高w,h)// 通过重采样复制和调整图像的一部分imagecopyresampled($canvas, $res, 0, 0, 0, 0, $val['width'], $val['height'],$resWidth,$resHeight);$val['left'] = $val['left']<0?$backgroundWidth- abs($val['left']) - $val['width']:$val['left'];$val['top'] = $val['top']<0?$backgroundHeight- abs($val['top']) - $val['height']:$val['top'];//2.上色$color = imagecolorallocate($canvas,229,231,230);//3.设置透明imagecolortransparent($canvas,$color);// 放置图像// PHP中的内置函数,用于将图像复制并合并为单个图像。如果成功,则此函数返回True;如果失败,则返回False。imagecopymerge($imageRes,$canvas, $val['left'],$val['top'],$val['right'],$val['bottom'],$val['width'],$val['height'],$val['opacity']);//左,上,右,下,宽度,高度,透明度}}//处理文字if(!empty($config['text'])){foreach ($config['text'] as $key => $val) {$val = array_merge($textDefault,$val);list($R,$G,$B) = explode(',', $val['fontColor']);$fontColor = imagecolorallocate($imageRes, $R, $G, $B);$val['left'] = $val['left']<0?$backgroundWidth- abs($val['left']):$val['left'];$val['top'] = $val['top']<0?$backgroundHeight- abs($val['top']):$val['top'];// PHP中的内置函数,用于使用TrueType字体将文本写入图像。// imagettftextSp// imagettftextimagettftext($imageRes,$val['fontSize'],$val['angle'],$val['left'],$val['top'],$fontColor,$val['fontPath'],$val['text']);}}// 处理成就 单独设置if(!empty($config['achieve'])){for ($ac = 0;$ac < count($config['achieve']["text"]);$ac++) {$text = $config['achieve']["text"];list($R,$G,$B) = explode(',',$config['achieve']['fontColor']);$fontColor = imagecolorallocate($imageRes, $R, $G, $B);$config['achieve']['top'] = $config['achieve']['top'] + 50;// PHP中的内置函数,用于使用TrueType字体将文本写入图像。// imagettftextSp// imagettftextimagettftext($imageRes,$config['achieve']['fontSize'],$config['achieve']['angle'],$config['achieve']['left'],$config['achieve']['top'],$fontColor,$config['achieve']['fontPath'],$text[$ac]);}}// 成就文字前五角星if (!empty($config['pentagram'])){// $this->Pentagramfor ($i = 0;$i < $this->Pentagram * 2;$i++){$iniptm = $config['pentagram'];$inipentagram = $iniptm['url'];// getimagesize() 函数用于获取图像大小及相关信息,成功返回一个数组,失败则返回 FALSE 并产生一条 E_WARNING 级的错误信息。$morepentagram = getimagesize($inipentagram);// 根据指定的图像类型返回对应的后缀名。$morefunction = 'imagecreatefrom'.image_type_to_extension($morepentagram[2], false);if($iniptm['stream']){   //如果传的是字符串图像流// 从字符串中获取图像尺寸信息。$inipentagram = getimagesizefromstring($iniptm['url']);// imagecreatefromstring 从字符串中的图像流新建一图像$morefunction = 'imagecreatefromstring';}$inipentagram = $morefunction($inipentagram);$morewidth = $morepentagram[0]; // 返回当前图片宽度$moreheight = $morepentagram[1]; // 返回当前图片高度// 创建新的true-color图像。此函数返回给定尺寸的空白图像。$moreimage = imageCreatetruecolor($iniptm['width'], $iniptm['height']);// 用给定的颜色填充图像。此函数以给定的坐标(图像的左上角为0、0)开始执行填充。imagefill($moreimage, 0, 0, $color);// 关键函数,参数(目标资源,源,目标资源的开始坐标x,y, 源资源的开始坐标x,y,目标资源的宽高w,h,源资源的宽高w,h)// 通过重采样复制和调整图像的一部分imagecopyresampled($moreimage,$inipentagram, 0, 0, 0, 0, $iniptm['width'], $iniptm['height'],$morewidth,$moreheight);$iniptm['left'] = $iniptm['left']<0?$backgroundWidth- abs($iniptm['left']) - $iniptm['width']:$iniptm['left'];$iniptm['top'] = $iniptm['top']<0?$backgroundHeight- abs($iniptm['top']) - $iniptm['height']:$iniptm['top'];//2.上色$color = imagecolorallocate($moreimage,229,231,230);//3.设置透明imagecolortransparent($moreimage,$color);// 放置图像// PHP中的内置函数,用于将图像复制并合并为单个图像。如果成功,则此函数返回True;如果失败,则返回False。// imagecopy// imagecopymerge($imageRes,$moreimage, $iniptm['left'],$iniptm['top'],$iniptm['right'],$iniptm['bottom'],$iniptm['width'],$iniptm['height'],$iniptm['opacity']);//左,上,右,下,宽度,高度,透明度imagecopy($imageRes,$moreimage, $iniptm['left'],$iniptm['top'] + $i++ * 24.5,$iniptm['right'],$iniptm['bottom'],$iniptm['width'],$iniptm['height']);//左,上,右,下,宽度,高度,透明度}}//生成图片if(!empty($filename)){// imagegif():以 GIF 格式将图像输出到浏览器或文件// imagejpeg():以 JPEG 格式将图像输出到浏览器或文件// imagepng():以 PNG 格式将图像输出到浏览器或文件// imagewbmp():以 WBMP 格式将图像输出到浏览器或文件$res = imagejpeg ($imageRes,$filename,90); //保存到本地// 销毁图像资源imagedestroy($imageRes);if(!$res) return false;return $filename;}else{imagejpeg ($imageRes);     //在浏览器上显示imagedestroy($imageRes);}}

其他方法

 // 因为文字表情无法显示,提供一个过滤表情的方法// 过滤掉emoji表情,在参数组装时调用,过滤掉表情function filterEmoji($str){$str = preg_replace_callback('/./u', function (array $match) {return strlen($match[0]) >= 4 ? '' : $match[0];}, $str);return $str;}// 文字换行public function getbrtext($width = 200, $size = 16, $angle = 0, $font = '../public/assets/fonts/5c8a05a7b3b641552549287.otf', $text = '',$type = '') {$hang = 1;//判断是否超出范围$str = "";for ($i = 0; $i < mb_strlen($text); $i++) {$letter[] = mb_substr($text, $i, 1);}foreach ($letter as $l) {$teststr = $str . " " . $l;$testbox = imagettfbbox($size, $angle, $font, $teststr);// 判断拼接后的字符串是否超过预设的宽度。超出宽度添加换行if (($testbox[2] > $width) && ($str !== "")) {$str .= "\n";$hang++;}$str .= $l;}if ($type == 1){// 获取简介文本高度// 行数$this->textRows = $hang;// 文字高$this->summary_height = $this->text_height($str,2,$hang);;}elseif ($type == 2){$this->bat_ga_textRows = $hang;// 获取诊疗文本高度$this->dat_height = $this->text_height($str,2,$hang);}else{// 获取擅长文本高度$this->good_at_height = $this->text_height($str,2,$hang);}//返回return $str;}// 获取文本的高度public function text_height ($text,$type,$hang) {$size = 12;//font height$box = $this->get_bbox(22,0,ROOT_PATH.'/public/assets/fonts/5c8a05a7b3b641552549287.otf',$text);if ($type == 1){$height = $box[3] - $box[5];}else{$width = abs($box[4] - $box[0]) + 10;$height = (35 * $hang);}return $height;}// 用于计算TrueType文本的边框(以像素为单位)。public function get_bbox($size = 16,$angle = 0,$font = ROOT_PATH.'/public/assets/fonts/5c8a05a7b3b641552549287.otf',$text = ''){/** imagettfbbox() 返回一个含有 8 个单元的数组表示了文本外框的四个角:* 0 左下角 X 位置* 1 左下角 Y 位置* 2 右下角 X 位置* 3 右下角 Y 位置* 4 右上角 X 位置* 5 右上角 Y 位置* 6 左上角 X 位置* 7 左上角 Y 位置*/return imagettfbbox($size, $angle, $font, $text);}// 字体间距public function imagettftextSp($image, $size, $angle, $x, $y, $color, $font, $text, $spacing = 0){if ($spacing == 0){imagettftext($image, $size, $angle, $x, $y, $color, $font, $text);}else{$temp_x = $x;for ($i = 0; $i < strlen($text); $i++){$bbox = imagettftext($image, $size, $angle, $temp_x, $y, $color, $font, $text[$i]);$temp_x += $spacing + ($bbox[2] - $bbox[0]);}}}/**去除html标签,并截取指定个字符* $contents 内容* $number 字数*/public function tagecontent($contents,$number='85'){$tagecontent = strip_tags($contents);$pattern = '/\s/';//去除空白$content = preg_replace($pattern, '', $tagecontent);$list = mb_substr($content,0,$number, "UTF-8");return $list;}

将就看
最后在后台下载图片,
在操作列添加下载按钮

buttons: [{name: 'ajax',title: __('发送Ajax'),classname: 'btn btn-xs btn-primary btn-magic btn-ajax',icon: 'fa fa-cloud-download',confirm: '确认发送下载海报图请求?',url: 'Poster/downloadImg/downloadImg/ids',success: function (data, ret) {var a = document.createElement('a');          // 创建一个a节点插入的documentvar event = new MouseEvent('click')           // 模拟鼠标click点击事件a.download = 'beautifulGirl'                  // 设置a节点的download属性值a.href = data;                                 // 将图片的src赋值给a节点的hrefa.dispatchEvent(event)//如果需要阻止成功提示,则必须使用return false;//return false;},error: function (data, ret) {console.log(data, ret);Layer.alert(ret.msg);return false;}},],
/*** 下载图片*/public function downloadImg($ids){if (!$this->request->isAjax()){$this->error('错误的信息');}$row = $this->model->get(['id' => $ids]);if($row['poster_image']){$poster_image = $this->request->domain() . $row['poster_image'];$this->success("请求成功", null,$poster_image);}else{$this->error(__('No Results were found'));}}

修改的时候判断是否有修改数据,先获取原数据,在使用 array_diff_assoc 对比提交的数据
array_diff:比较两个数组的值,并返回差集
array_diff_assoc:比较两个数组的键名和键值,并返回差集

tp5.0 FAST 生成海报图相关推荐

  1. 前端生成海报图:html2canvas 生成海报图/网页html转图片

    html2canvas 生成海报图 <html><head> <title>生成海报图Demo</title> </head><bod ...

  2. PHP使用Grafika合成图片,生成海报图

    需求背景: 在小程序上生成海报图,但在保存图片时,只能保存其中的小程序码图片,保存下来的图片过于单调,且无法确认该图片的作用性,所以需要调整为保存一整张海报图. 海报效果图: 需求分析: 在海报图中, ...

  3. html2canvas手机黑屏,html2canvas 生成海报图 开发中遇到的问题

    ios里,生成的图片不显示 canvas.toDataURL('image/jpeg', 1.0) 使用image/jpeg格式,在指定图片格式为 image/jpeg 或 image/webp的情况 ...

  4. uniapp app端使用html2canvas和renderjs实现生成海报图

    uniapp app端使用html2canvas和renderjs实现生成海报图 原本app端是无法使用html2canvas的因为,app端不支持浏览器js. 不过我在uniapp里面看到了rend ...

  5. tp5 fast 在生成海报图中文字竖列排序

    生成海报得时候又一列文字需要竖列排序,并且是4个文字一列,最多八个文字,也就有两列,要是少于8个,就需要吧少得那一列上下居中布局,也就是在少得那一列往上加高度就行 就在网上看看demo,下面是垂直文本 ...

  6. vue- canvas生成海报图

    此图为生成的海报图. git链接:https://github.com/sunniejs/vue_canvas_poster 1.通过cnpm安装 cnpm i vue-canvas-poster - ...

  7. 在微信小程序中实现生成海报图并保存到相册

    效果图镇楼: 技术依赖: 弹窗 (vant-weapp 提供的 van-popup 组件) 海报图 (wx-canvas-2d 工具) 弹窗组件的使用方式可以点击上面链接查看,本篇主要讲解海报图绘制方 ...

  8. vue-canvas生成海报图

    此图为生成的海报图. git链接:https://github.com/sunniejs/vue_canvas_poster 文档:https://sunniejs.github.io/vue-can ...

  9. 微信小程序 —— canvas生成海报图与分享

    整体思路 获取手机屏幕大小去依据设计尺寸比例调整 -wx.getSystemInfo 网络图片.base64图片保存到到本地临时文件路径 canvas绘制图片 - wx.createCanvasCon ...

最新文章

  1. datatables插件AJAX请求数据报错Uncaught TypeError: Cannot read property ‘length‘ of undefined
  2. 21行代码AC——习题5-1 代码对齐(Alignment of Code, UVa1593)——解题报告
  3. LeetCode 404左叶子之和-简单
  4. 程序员千万不要做舔狗啊!
  5. 【python基础知识】AttributeError: module 'turtle' has no attribute 'setup'
  6. CCF NOI1118 序列第K小
  7. php课后答案 唐四薪_PHP课后小结 12.20
  8. 微波遥感SNAP(三)——检测地表沉降(1)自动化处理(Graph Builder)
  9. FileInputStream实现读取文件内容并输出到屏幕上
  10. qt实现简易的画图,鼠标事件
  11. 【摘抄】为什么要学C语言
  12. c语言根号sin60,用泰勒级数展开求sin60°的值C语言
  13. python课程总结-Python课程学习总结
  14. muduo网络库:09---多线程服务器之(单线程、多线程服务器的适用场合)
  15. java 字符串不等于_java中字符串不等于怎么判断
  16. js xlsx自定义样式导出
  17. SystemProperties与Settings.system
  18. 学习笔记:深度学习(3)——卷积神经网络(CNN)理论篇
  19. 页面提交后提示“连接被重置”或“载入页面时到服务器的连接被重置”的问题分析
  20. 成长陪伴 | 志愿者牵手逆风宝贝共享快乐周末

热门文章

  1. 最新风控模型竞赛开始了,金融大数据应用-企业信贷风险防控-中国建设银行数据集
  2. 我的2016,成长之路总是充满坎坷
  3. 一、docker容器使用以及搭建企业级web网站
  4. C语言画菜单函数(只为方便手机端学习用户)
  5. 使用Spring-Data-Redis存储对象(redisTemplate)
  6. 读书的意义(转载于B站)
  7. c语言错误必须定义入口点,MFC项目中:报错:“fatal error LNK1561: 必须定义入口点”解决方法...
  8. 卷积神经网络模型之——LeNet网络
  9. flutter的核心库
  10. JavaScript学习笔记:JSON