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.
## 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
SolutionThe 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.
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!
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