Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to generate posters by TP5.1

Shulou Source: shulou.com Published: 2022-06-01 23:16:20 11月16日 Update

Editor to share with you how to generate TP5.1 posters, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

/ / remote download function downImg ($imgUrl, $savePath ='', $filename ='') {if (! isDirFile ($savePath)) {mkdir ($savePath,0777,true);} if ($savePath = =') {return false;} $ch = curl_init (); curl_setopt ($ch, CURLOPT_URL, $imgUrl); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 30) Curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, false); / / this is the point. $file = curl_exec ($ch); curl_close ($ch); $ext = pathinfo ($imgUrl,PATHINFO_EXTENSION); if (! $ext) $ext = 'png'; $resource = fopen ($savePath. $filename. '. $ext,' w'); $res = fwrite ($resource, $file); fclose ($resource); if ($res) {return $filename. '. $ext;} else {return false;}} / / generate thumbnails function imgToThumb ($imgUrl) {$image =\ think\ Image::open ($imgUrl); $image- > thumb (104,104)-> radius (50)-> save ($imgUrl);} / / determine whether function isDirFile ($path,$isfile = false) {if ($isfile) {return file_exists ($path) exists in the file or directory? True: false;} else {return is_dir ($path)? True: false;}} / / Watermark function water ($codefile,$text,$newFile,$waterBg= ". / uploads/haibao.jpg") {/ / determine picture size-generate thumbnail list ($width, $height, $type, $attr) = getimagesize ($codefile); if ($width > 104 | | $height > 104) {imgToThumb ($codefile);} if (! isDirFile (\ Env::get ('root_path').' public/'.$waterBg,true)) {return false } $image =\ think\ Image::open ($waterBg); / * if ($strlen > 8) {$text = mb_substr ($text,0,8,'UTF-8'). '...; $offset = [380985];} * / $textName = isset ($text [0])? $text [0]:'; $textData = isset ($text [1])? $text [1]:'' $textDays = isset ($text [2])? $text [2]:'; $textNums = isset ($text [3])? $text [3]:'' $image- > text ($textName,\ Env::get ('root_path').' public/static/font/msyh.ttf',24,'#323232', [150822])-> text ($textData,\ Env::get ('root_path').' public/static/font/msyh.ttf',14,'#c5a98f', [150864])-> text ($textDays,\ Env::get ('root_path'). [360810])-> text ($textNums,\ Env::get ('root_path').' public/static/font/msyh.ttf',46,'#9e7758', [540810])-> water ($codefile, [36804])-> save ($newFile) Return $newFile;} above is all the content of the article "how to generate posters in TP5.1". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Generate articles posters content pictures not much most size documents more watermarks directories knowledge industry information information channels key points channels references learning Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Xiaomi vpn Microsoft Huawei