Home >CMS Tutorial >PHPCMS >What should I do if phpcms cannot add watermark?
What should I do if phpcms cannot add watermark?
phpcms remote image localization failure and watermark function failure tutorial
The specific modifications are as follows: include/attachment.class.php added a function
The code is as follows:
function ycimg($file,$newfile) { // 初始化一个 cURL 对象 $curl = curl_init(); // 设置你需要抓取的URL curl_setopt($curl, CURLOPT_URL, $file); // 设置header curl_setopt($curl, CURLOPT_HEADER, 0); // 设置cURL 参数,要求结果保存到字符串中还是输出到屏幕上。 curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // 运行cURL,请求网页 $data = curl_exec($curl); // 关闭URL请求 curl_close($curl); //写入获得的数据 $write = @fopen($newfile,"w"); fwrite($write,$data); fclose($write); return TRUE; }
There may be a small problem here. However, it can be successfully captured during the test. So it directly returns TRUE. Interested friends can continue to improve this function.
Then find
if(@$upload_func($file, $newfile))
in this file and modify it to:
if($this->ycimg($file,$newfile))
Finally remove:
@chmod($newfile, 0777);
This section of code.
is captured remotely like this The success rate is very high. During local testing, the success rate is 100%, while the success rate of the copy function is less than 70%...
As mentioned above, network factors have a greater impact.
Then there is the function of adding watermarks to remotely saved pictures.
It is still the same file. Find the following code:
$this->downloadedfiles[$aid] = $filepath;
Add the following code below:
The code is as follows:
$waterpath = UPLOAD_URL.$filepath; require_once 'image.class.php'; $image = new image(); $image->watermark($waterpath, '', '9', 'images/watermark.gif', '', '5', '#ff0000', '80','100');
The watermark parameters can only be adjusted here, and the settings in the system are invalid...
PHP Chinese website, a large number of free PHPCMS tutorials, welcome to learn online!
The above is the detailed content of What should I do if phpcms cannot add watermark?. For more information, please follow other related articles on the PHP Chinese website!