Home  >  Article  >  Backend Development  >  What to do if the picture is not clear after drawing in php

What to do if the picture is not clear after drawing in php

藏色散人
藏色散人Original
2022-12-14 09:24:075750browse

Solution to the unclear picture after php drawing: 1. Open the corresponding php code file; 2. Check the "magejpeg()" function; 3. Modify the parameters in the function, and the statement is "imagejpeg($ resource_img, $save_image, 100);"; 4. Release the memory occupied by the image resource.

What to do if the picture is not clear after drawing in php

The operating environment of this tutorial: Windows 7 system, PHP version 8.1, Dell G3 computer.

The picture is not clear after drawing in php? The pictures generated/saved by PHP are not clear?

The problem I encountered is that when I use imagejpeg to save pictures, the saved pictures are not clear

Reason: imagejpeg() has a unique parameter quality, this parameter The default value is 75, just set this parameter to 100

imagejpeg($resource_img, $save_image, 100);

Note: Other methods, such as imagegif() and imagepng() do not have this parameter.

Also, after processing the image, remember to release the memory occupied by the image resource~

Related introduction:

imagejpeg

(PHP 4, PHP 5, PHP 7, PHP 8)

imagejpeg — Output image to browser or file.

Description

imagejpeg(resource $image, string $filename = ?, int $quality = ?): bool

imagejpeg() Creates a JPEG image from the image image with filename as the file name.

Parameters

image

The GdImage object returned by the image creation function (such as imagecreatetruecolor()).

filename

The path where the file is saved or the opened stream resource (the stream resource is automatically closed after this method returns). If it is not set or is null, the original image stream will be output directly. .

If you want to omit this parameter and provide the quality parameter, use NULL.

quality

quality is optional and ranges from 0 (worst quality, smaller file size) to 100 (best quality, largest file size). Defaults to IJG's default quality value (approximately 75).

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of What to do if the picture is not clear after drawing in php. 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