How to solve the garbled problem of php imagecreate

藏色散人
Release: 2023-03-13 14:36:02
Original
1904 people have browsed it

php imagecreate garbled solution: 1. Create a canvas through imagecreate; 2. Use imagecolorallocate to set the background color of the canvas; 3. Set "header('content-type:image/gif');" .

How to solve the garbled problem of php imagecreate

The operating environment of this article: Windows7 system, PHP7.1 version, DELL G3 computer

How to solve the garbled problem of php imagecreate?

Solution to the problem that PHP becomes garbled when creating an image (GD)

Problematic code:

nbsp;html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<meta>
<title>php学习</title>


<?php  
$im=imagecreate(200,200);  
//创建一个画布(单位像素pixel)
$white=imagecolorallocate($im,225,66,159); 
//设置画布的背景颜色为粉色 (256RGB)
imagegif($im);  
//输出gif图像
imagedestroy($im); 
?>
 
 
Copy after login

Running result:
How to solve the garbled problem of php imagecreate

Modified code:

<?php  
$im=imagecreate(200,200); 
//创建一个画布(单位像素pixel)
$white=imagecolorallocate($im,225,66,159); 
//设置画布的背景颜色为粉色 (256RGB)
header(&#39;content-type:image/gif&#39;);  
//设置gif 
Imageimagegif($im); 
//输出gif图像
imagedestroy($im); 
?>
Copy after login

Running results:
How to solve the garbled problem of php imagecreate Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to solve the garbled problem of php imagecreate. 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