How to solve php imagepng error problem

藏色散人
Release: 2023-03-11 08:34:01
Original
2588 people have browsed it

php imagepng reports an error because the quality range of the image generated by ImagePNG is from 0 to 9. When parameters outside this range are passed in, the function will not work. The solution is to change the value to 0 to 9. , the error will disappear on its own.

How to solve php imagepng error problem

## The operating environment of this article: Windows 7 system, PHP version 7.1 , DELL G3 computer

How to solve the php imagepng error problem?

php error when uploading pictures: gd-png error: compression level must be 0 through 9


Error report


Warning: imagepng (): gd-png error: compression level must be 0 through 9


How to solve php imagepng error problem

Solution

The quality of the image generated by JPEG image is a range from 0 (the lowest quality, smallest file size) to 100 (highest quality, largest file size).

imagejpeg($imgSource, $path, 100);
Copy after login

The reason for this error is because the quality of the image generated by ImagePNG ranges from 0 to 9. If the parameters passed in are outside this range, the function will not work. So, simply change the value to between 0 and 9 and the error will go away on its own.

imagepng($imgSource, $path, 9);
Copy after login

Recommended study: "

PHP Video Tutorial"

The above is the detailed content of How to solve php imagepng error problem. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!