Today to share the Chinese watermark and picture watermark Integrated plug-in, thinkphp only separate add text or add pictures, because the need to work with the Riga "text" and "picture" so, try to modify a bit, only one line of code to solve the image and text watermark. First, the image method of thinkphp is introduced, and the Chinese watermark is supported.
1. Front-End Template: Front-end original picture and watermark image display contrast <p class= "notice Red" > Original: </p>
<p class= "notice Red" Style= "margin:10px 0" > After Chinese watermark: </p>
2, the main controller introduced thinkphp Watermark class
<?phpnamespace home\controller;use think\controller;header (" Content-type:text/html;charset=utf-8 ");class indexcontroller extends controller { public function index () { $ Image = new \think\image (); $str = " Two-headed generation watermark picture Time: " . date (" y-m-d h:i:s ") . " "; $image->open (' public/images/original.jpg ')->water (' Public/images/water_bg.png ')->text ($ str, ' Public/images/simhei.ttf ', 14, ' #FFFFFF ', \think\image::image_water_southeast, -20)->save ("Public/images/new.jpg"); $this->display (); }}?>
please take away the children's shoes if necessary . Demo Address: http://www.erdangjiade.com/php/937.html
thinkphp Chinese watermark and Picture watermark Integrated plug-in