Home Backend Development PHP Tutorial imagepng的奇怪有关问题

imagepng的奇怪有关问题

Jun 13, 2016 pm 01:20 PM
imagepng png quot

imagepng的奇怪问题
代码如下,奇怪的是把imagepng($im)改为imagepng($im,"kk.png")可以得到图片但是直接输出至浏览器就是显示不出来,一直是红叉,这段代码在另一台机器上能正常运行。是我的php配置问题吗?

header("Content-type: image/png");
srand((double)microtime()*1000000);
$login_check_number=strval(rand("11111","99999"));
//$session->setMember("loginCheckNumber", $login_check_number);

$im = imagecreate(50,20) or die ("Cannot Initialize new GD image stream");
$black = ImageColorAllocate($im, 9,142,204);
$foreColor = ImageColorAllocate($im, 0,0,0);
$white = ImageColorAllocate($im, 255,255,255);
imageline($im, 1, 1, 350, 25, $black);
imagearc($im, 200, 15, 20, 20, 35, 190, $white);
imagestring($im, 5, 7, 3, $login_check_number, $white);
for($i=0 ; $i {
imagesetpixel($im, rand()%50 , rand()%50 , $foreColor);
}

imagepng($im);
imagedestroy($im);
?>


------解决方案--------------------

探讨
引用:
引用:
GD库没开的话imagepng($im,"kk.png")能生成kk.png文件吗?

那应该是和浏览器有关
把第一句换成试试 header("Content-type: image/x-png");


换过也不行
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

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 Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1670
14
PHP Tutorial
1274
29
C# Tutorial
1256
24
How to convert PNG to JPG on Windows 11 How to convert PNG to JPG on Windows 11 May 12, 2023 pm 03:55 PM

How to Convert PNG to JPG on Windows 11 On Windows 10 and 11, you can use Microsoft's built-in Paint app to quickly convert image files. To convert a PNG image to JPG on Windows 11, use the following steps: Open File Explorer and navigate to the PNG image you want to convert. Right-click the image and select Open With > Draw from the menu. Your photo or image opens in the Paint app. Note the file size at the bottom of the screen. To convert a file from PNG to JPG, click File and select Save As > JPEG Image from the menu. When the file resource

How to rename the extension of all files within a folder, including subfolders How to rename the extension of all files within a folder, including subfolders Apr 14, 2023 pm 12:22 PM

Suppose you need to rename the extension of a file from one extension to another, say jpg to png. It's easy, of course! But what if you have multiple files whose extensions need to be changed? Or worse, what if these multiple files are also located in multiple folders and subfolders, within a single folder? Well, for a normal person, this can be a nightmare. But for a geek, absolutely not. The question now is, are you a geek? Well, with the help of Geek Page, you definitely are! In this article, we explain how to easily rename the extension of all files within a folder, including subfolders of your choice, from one extension to another through a batch script method. Notice:

php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 Jun 13, 2016 am 10:23 AM

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

What format is png? What format is png? Dec 10, 2020 pm 04:16 PM

png is a bitmap format that uses a lossless compression algorithm. The PNG format has three forms: 8-bit, 24-bit, and 32-bit. The 8-bit PNG supports two different transparent forms. The 24-bit PNG does not support transparency. The 32-bit PNG adds an 8-bit transparent channel to the 24-bit. Therefore, Can display 256 levels of transparency.

How to make pictures into png How to make pictures into png Jan 19, 2021 am 09:14 AM

How to make a picture into a png: 1. Open the PS software; 2. Find the picture that needs to be processed and import it into the software; 3. Adjust the background color of the picture to white; 4. Select the "Magic Eraser" tool and click The background area on the picture that needs to be made transparent; 5. Click "File" - "Save As" in the menu bar, select "png" in the save format in the pop-up window, and export the picture in png format.

What format is png file? What format is png file? Feb 21, 2024 pm 09:30 PM

PNG is a common image file format. It is a lossless compression format, which means that it does not lose image quality. PNG stands for Portable Network Graphics. The PNG file format was originally created by a group of developers in 1996 and was intended to replace some limited and inefficient file formats such as GIF. The PNG file format is based on a lossless compression algorithm and utilizes indexes, palettes, and grayscale images to store image data. Compared to other image formats, PN

What is the format of png files? What is the format of png files? Feb 19, 2024 pm 08:32 PM

PNG is a common image file format, whose full name is "Portable Network Graphics". It is a lossless compression format designed to replace the JPEG and GIF formats commonly used in the past. The PNG format was created in 1995 by graphic designer Thomas Boutell and grew in popularity over the following years. The PNG format is characterized by supporting high-quality image compression while retaining image details and color information. Comparable to JPEG format

Which one is clearer, jpeg or png? Which one is clearer, jpeg or png? Mar 17, 2023 am 10:43 AM

Compared with jpeg and png, the png format is clearer; because the png format is a lossless format, while the jpeg format is lossy compression, which will reduce the quality of the original image data; therefore, if you use files produced by drawing software, save When you choose to save the png format, it will be clearer than the jpeg format.

See all articles