📄 function.imagepng.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Output a PNG image to either the browser or a file</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.imagepalettecopy.html">imagepalettecopy</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.imagepolygon.html">imagepolygon</a></div> <div class="up"><a href="ref.image.html">GD Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.imagepng" class="refentry"> <div class="refnamediv"> <h1 class="refname">imagepng</h1> <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">imagepng</span> — <span class="dc-title">Output a PNG image to either the browser or a file</span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">bool</span> <span class="methodname"><b><b>imagepng</b></b></span> ( <span class="methodparam"><span class="type">resource</span> <tt class="parameter">$image</tt></span> [, <span class="methodparam"><span class="type">string</span> <tt class="parameter">$filename</tt></span> [, <span class="methodparam"><span class="type">int</span> <tt class="parameter">$quality</tt></span> [, <span class="methodparam"><span class="type">int</span> <tt class="parameter">$filters</tt></span> ]]] )</div> <p class="para rdfs-comment"> Outputs or saves a <acronym title="Portable Network Graphics">PNG</acronym> image from the given <i><tt class="parameter">image</tt></i>. </p> </div> <div class="refsect1 parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt><span class="term"><i><tt class="parameter">image</tt></i></span><dd><p class="para">An image resource, returned by one of the image creation functions, such as <a href="function.imagecreatetruecolor.html" class="function">imagecreatetruecolor()</a>.</p></dd></dt> <dt> <span class="term"><i><tt class="parameter">filename</tt></i></span> <dd> <p class="para"> The path to save the file to. If not set or <b><tt>NULL</tt></b>, the raw image stream will be outputted directly. </p> <blockquote><p><b class="note">Note</b>: <b><tt>NULL</tt></b> is invalid if the <i><tt class="parameter">quality</tt></i> and <i><tt class="parameter">filters</tt></i> arguments are not used. <br /> </p></blockquote> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">quality</tt></i></span> <dd> <p class="para"> Compression level: from 0 (no compression) to 9. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">filters</tt></i></span> <dd> <p class="para"> Allows reducing the PNG file size. It is a bitmask field which may be set to any combination of the <i>PNG_FILTER_XXX</i> constants. <b><tt>PNG_NO_FILTER</tt></b> or <b><tt>PNG_ALL_FILTERS</tt></b> may also be used to respectively disable or activate all filters. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns <b><tt>TRUE</tt></b> on success or <b><tt>FALSE</tt></b> on failure. </p> </div> <div class="refsect1 changelog"> <h3 class="title">ChangeLog</h3> <p class="para"> <table class="informaltable"> <colgroup> <thead valign="middle"> <tr valign="middle"> <th colspan="1">Version</th> <th colspan="1">Description</th> </tr> </thead> <tbody valign="middle" class="tbody"> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">5.1.3</td> <td colspan="1" rowspan="1" align="left"> Added the <i><tt class="parameter">filters</tt></i> parameter. </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">5.1.2</td> <td colspan="1" rowspan="1" align="left"> Added the <i><tt class="parameter">quality</tt></i> parameter. </td> </tr> </tbody> </colgroup> </table> </p> </div> <div class="refsect1 examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="informalexample"> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br />$im </span><span style="color: #007700">= </span><span style="color: #0000BB">imagecreatefrompng</span><span style="color: #007700">(</span><span style="color: #DD0000">"test.png"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">header</span><span style="color: #007700">(</span><span style="color: #DD0000">'Content-type: image/png'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">imagepng</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">imagedestroy</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> </div> </p> </div> <div class="refsect1 seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"><a href="function.imagegif.html" class="function" rel="rdfs-seeAlso">imagegif()</a></li> <li class="member"><a href="function.imagewbmp.html" class="function" rel="rdfs-seeAlso">imagewbmp()</a></li> <li class="member"><a href="function.imagejpeg.html" class="function" rel="rdfs-seeAlso">imagejpeg()</a></li> <li class="member"><a href="function.imagetypes.html" class="function" rel="rdfs-seeAlso">imagetypes()</a></li> <li class="member"><a href="function.imagesavealpha.html" class="function" rel="rdfs-seeAlso">imagesavealpha()</a></li> </ul> </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.imagepalettecopy.html">imagepalettecopy</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.imagepolygon.html">imagepolygon</a></div> <div class="up"><a href="ref.image.html">GD Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -