search
HomeCMS TutorialPHPCMSWhat should I do if phpcms cannot add watermark?

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!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software