function.imagerotate.html

来自「php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容」· HTML 代码 · 共 178 行

HTML
178
字号
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head>  <title>Rotate an image with a given angle</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.imagerectangle.html">imagerectangle</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.imagesavealpha.html">imagesavealpha</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.imagerotate" class="refentry"> <div class="refnamediv">  <h1 class="refname">imagerotate</h1>  <p class="verinfo">(PHP 4 &gt;= 4.3.0, PHP 5)</p><p class="refpurpose"><span class="refname">imagerotate</span> &mdash; <span class="dc-title">Rotate an image with a given angle</span></p> </div> <div class="refsect1 description">  <h3 class="title">Description</h3>  <div class="methodsynopsis dc-description">   <span class="type">resource</span> <span class="methodname"><b><b>imagerotate</b></b></span>    ( <span class="methodparam"><span class="type">resource</span> <tt class="parameter">$image</tt></span>   , <span class="methodparam"><span class="type">float</span> <tt class="parameter">$angle</tt></span>   , <span class="methodparam"><span class="type">int</span> <tt class="parameter">$bgd_color</tt></span>   [, <span class="methodparam"><span class="type">int</span> <tt class="parameter">$ignore_transparent</tt></span>  ] )</div>  <p class="para rdfs-comment">   Rotates the <i><tt class="parameter">image</tt></i> image using the given   <i><tt class="parameter">angle</tt></i> in degrees.   </p>  <p class="para">   The center of rotation is the center of the image, and the rotated   image is scaled down so that the whole rotated image fits in the   destination image - the edges are not clipped.  </p>  <p class="para">  </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">angle</tt></i></span>     <dd>      <p class="para">       Rotation angle, in degrees.      </p>     </dd>    </dt>    <dt>     <span class="term"><i><tt class="parameter">bgd_color</tt></i></span>     <dd>      <p class="para">       Specifies the color of the uncovered zone after the rotation      </p>     </dd>    </dt>    <dt>     <span class="term"><i><tt class="parameter">ignore_transparent</tt></i></span>     <dd>      <p class="para">       If set and non-zero, transparent colors are ignored (otherwise kept).      </p>     </dd>    </dt>   </dl>  </p> </div> <div class="refsect1 returnvalues">  <h3 class="title">Return Values</h3>  <p class="para">  </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.0</td>       <td colspan="1" rowspan="1" align="left">        <i><tt class="parameter">ignore_transparent</tt></i> was added.       </td>      </tr>     </tbody>    </colgroup>   </table>  </p> </div> <div class="refsect1 examples">  <h3 class="title">Examples</h3>  <p class="para">   <div class="example">    <p><b>Example #1 Rotate an image 180 degrees</b></p>    <div class="example-contents"><p>     This example rotates an image 180 degrees - upside down.    </p></div>    <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;File&nbsp;and&nbsp;rotation<br /></span><span style="color: #0000BB">$filename&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'test.jpg'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$degrees&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">180</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//&nbsp;Content&nbsp;type<br /></span><span style="color: #0000BB">header</span><span style="color: #007700">(</span><span style="color: #DD0000">'Content-type:&nbsp;image/jpeg'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;Load<br /></span><span style="color: #0000BB">$source&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">imagecreatefromjpeg</span><span style="color: #007700">(</span><span style="color: #0000BB">$filename</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;Rotate<br /></span><span style="color: #0000BB">$rotate&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">imagerotate</span><span style="color: #007700">(</span><span style="color: #0000BB">$source</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$degrees</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;Output<br /></span><span style="color: #0000BB">imagejpeg</span><span style="color: #007700">(</span><span style="color: #0000BB">$rotate</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>    </div>    <div class="example-contents"><p>The above example will output something similar to:</p></div>    <div class="mediaobject">     <div class="imageobject">      <img src="figures/image.imagerotate.jpg" />     </div>    </div>   </div>  </p> </div> <div class="refsect1 notes">  <h3 class="title">Notes</h3>  <blockquote><p><b class="note">Note</b>: <span class="simpara">This function is only available ifPHP is compiled with the bundled version of the GD library.</span></p></blockquote> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.imagerectangle.html">imagerectangle</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.imagesavealpha.html">imagesavealpha</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 + =
减小字号Ctrl + -
显示快捷键?