700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > php基于Imagick实现添加水印 文字的图片功能

php基于Imagick实现添加水印 文字的图片功能

时间:2021-06-30 16:39:01

相关推荐

php基于Imagick实现添加水印 文字的图片功能

后端开发|php教程

php,Imagick,生成图片

后端开发-php教程

本篇文章主要介绍php基于Imagick实现添加水印、文字的图片功能,感兴趣的朋友参考下,希望对大家有所帮助。

易语言制作在线更新源码,ubuntu上面安装软件,爬虫cookies 模拟登录,收款聚合+php,jomin-seolzw

这里使用Imagick 生成图片

聊吧同城源码,ubuntu获取当前小时,爬虫合规吗,php gd图库,seo发文技巧lzw

解决了图片写中文文字乱码问题,添加支持的字体

android 录音源码,vscode怎么切换文件夹,平板电脑 ubuntu,tomcat管理界面默认密码,sql导出sqlite,网页设计 平面设计,建虚拟主机服务器吗,帝国畅言插件,php前端框架vue,爬虫阿拉丁,php查询mysql数据库,可信的seo优化,创建文件锁springboot,网站后台如何添加新闻,后台管理系统网页模版,asp实现自定义标签模板,织梦后台批量上传图片,单页面实现方法有哪些,java学生管理系统项目,网站程序模板下载lzw

public function getPic(){ header(Content-Type: text/html; charset=utf-8); $text = 中粮屯河(sh600737);//中粮屯河(sh600737) $watermark = 305988103123zczcxzas; $len = strlen($text); $width = 10.5*(($len-8)/3*2+8); $height = 26; $imagick = new Imagick(); $color_transparent = new ImagickPixel(#ffffff); //transparent 透明色 $imagick->newImage($width, $height, $color_transparent, jpg); //$imagick->borderimage(#000000, 1, 1); $style[font_size] = 12; $style[fill_color] = #000000; for($num= strlen($watermark); $num>=0; $num--){ $this->add_text($imagick,substr($watermark, $num,1), 2+($num*8), 30, 1,$style); $this->add_text($imagick,substr($watermark, $num,1), 2+($num*8), 5, 1,$style); } //return; $style[font_size] = 20; $style[fill_color] = #FF0000; $style[font] = ./msyh.ttf; ///微软雅黑字体 解决中文乱码 //$text=mb_convert_encoding($text,UTF-8); //iconv("GBK","UTF-8//IGNORE",$text); $this->add_text($imagick,$text, 2, 20, 0,$style); header ( Content-type: . strtolower ($imagick->getImageFormat ()) ); echo $imagick->getImagesBlob ();}// 添加水印文字public function add_text(& $imagick, $text, $x = 0, $y = 0, $angle = 0, $style = array()) { $draw = new ImagickDraw (); if (isset ( $style [font] )) $draw->setFont ( $style [font] ); if (isset ( $style [font_size] )) $draw->setFontSize ( $style [font_size] ); if (isset ( $style [fill_color] )) $draw->setFillColor ( $style [fill_color] ); if (isset ( $style [under_color] )) $draw->setTextUnderColor ( $style [under_color] ); if (isset ( $style [font_family] )) $draw->setfontfamily( $style [font_family] ); if (isset ( $style [font] )) $draw->setfont($style [font] ); $draw->settextencoding(UTF-8); if (strtolower ($imagick->getImageFormat ()) == gif) { foreach ( $imagick as $frame ) { $frame->annotateImage ( $draw, $x, $y, $angle, $text ); } } else { $imagick->annotateImage ( $draw, $x, $y, $angle, $text ); }}

总结:

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。