<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Set the alpha blending flag to use the bundled libgd layering effects</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.imagejpeg.html">imagejpeg</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.imageline.html">imageline</a></div> <div class="up"><a href="ref.image.html">GD and Image Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="function.imagelayereffect" class="refentry"> <div class="refnamediv"> <h1 class="refname">imagelayereffect</h1> <p class="verinfo">(PHP 4 >= 4.3.0, PHP 5)</p><p class="refpurpose"><span class="refname">imagelayereffect</span> — <span class="dc-title">Set the alpha blending flag to use the bundled libgd layering effects</span></p> </div> <div class="refsect1 description" id="refsect1-function.imagelayereffect-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">bool</span> <span class="methodname"><strong>imagelayereffect</strong></span> ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$image</code></span> , <span class="methodparam"><span class="type">int</span> <code class="parameter">$effect</code></span> )</div> <p class="para rdfs-comment"> Set the alpha blending flag to use the bundled libgd layering effects. </p> </div> <div class="refsect1 parameters" id="refsect1-function.imagelayereffect-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter"> image</code></em></span><dd> <p class="para">An image resource, returned by one of the image creation functions, such as <span class="function"><a href="function.imagecreatetruecolor.html" class="function">imagecreatetruecolor()</a></span>.</p></dd> </dt> <dt> <span class="term"><em><code class="parameter">effect</code></em></span> <dd> <p class="para"> One of the following constants: <dl> <dt> <span class="term"><strong><code>IMG_EFFECT_REPLACE</code></strong></span> <dd> <span class="simpara"> Use pixel replacement (equivalent of passing <strong><code>TRUE</code></strong> to <span class="function"><a href="function.imagealphablending.html" class="function">imagealphablending()</a></span>) </span> </dd> </dt> <dt> <span class="term"><strong><code>IMG_EFFECT_ALPHABLEND</code></strong></span> <dd> <span class="simpara"> Use normal pixel blending (equivalent of passing <strong><code>FALSE</code></strong> to <span class="function"><a href="function.imagealphablending.html" class="function">imagealphablending()</a></span>) </span> </dd> </dt> <dt> <span class="term"><strong><code>IMG_EFFECT_NORMAL</code></strong></span> <dd> <span class="simpara"> Same as <strong><code>IMG_EFFECT_ALPHABLEND</code></strong>. </span> </dd> </dt> <dt> <span class="term"><strong><code>IMG_EFFECT_OVERLAY</code></strong></span> <dd> <span class="simpara"> Overlay has the effect that black background pixels will remain black, white background pixels will remain white, but grey background pixels will take the colour of the foreground pixel. </span> </dd> </dt> </dl> </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.imagelayereffect-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns <strong><code>TRUE</code></strong> on success or <strong><code>FALSE</code></strong> on failure. </p> </div> <div class="refsect1 examples" id="refsect1-function.imagelayereffect-examples"> <h3 class="title">Examples</h3> <div class="example" id="example-3258"> <p><strong>Example #1 <span class="function"><strong>imagelayereffect()</strong></span> example</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br /></span><span style="color: #FF8000">// Setup an image<br /></span><span style="color: #0000BB">$im </span><span style="color: #007700">= </span><span style="color: #0000BB">imagecreatetruecolor</span><span style="color: #007700">(</span><span style="color: #0000BB">100</span><span style="color: #007700">, </span><span style="color: #0000BB">100</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Set a background<br /></span><span style="color: #0000BB">imagefilledrectangle</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">100</span><span style="color: #007700">, </span><span style="color: #0000BB">100</span><span style="color: #007700">, </span><span style="color: #0000BB">imagecolorallocate</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">, </span><span style="color: #0000BB">220</span><span style="color: #007700">, </span><span style="color: #0000BB">220</span><span style="color: #007700">, </span><span style="color: #0000BB">220</span><span style="color: #007700">));<br /><br /></span><span style="color: #FF8000">// Apply the overlay alpha blending flag<br /></span><span style="color: #0000BB">imagelayereffect</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">, </span><span style="color: #0000BB">IMG_EFFECT_OVERLAY</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Draw two grey ellipses<br /></span><span style="color: #0000BB">imagefilledellipse</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">, </span><span style="color: #0000BB">50</span><span style="color: #007700">, </span><span style="color: #0000BB">50</span><span style="color: #007700">, </span><span style="color: #0000BB">40</span><span style="color: #007700">, </span><span style="color: #0000BB">40</span><span style="color: #007700">, </span><span style="color: #0000BB">imagecolorallocate</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">, </span><span style="color: #0000BB">100</span><span style="color: #007700">, </span><span style="color: #0000BB">255</span><span style="color: #007700">, </span><span style="color: #0000BB">100</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">imagefilledellipse</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">, </span><span style="color: #0000BB">50</span><span style="color: #007700">, </span><span style="color: #0000BB">50</span><span style="color: #007700">, </span><span style="color: #0000BB">50</span><span style="color: #007700">, </span><span style="color: #0000BB">80</span><span style="color: #007700">, </span><span style="color: #0000BB">imagecolorallocate</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">, </span><span style="color: #0000BB">100</span><span style="color: #007700">, </span><span style="color: #0000BB">100</span><span style="color: #007700">, </span><span style="color: #0000BB">255</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">imagefilledellipse</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">, </span><span style="color: #0000BB">50</span><span style="color: #007700">, </span><span style="color: #0000BB">50</span><span style="color: #007700">, </span><span style="color: #0000BB">80</span><span style="color: #007700">, </span><span style="color: #0000BB">50</span><span style="color: #007700">, </span><span style="color: #0000BB">imagecolorallocate</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">, </span><span style="color: #0000BB">255</span><span style="color: #007700">, </span><span style="color: #0000BB">100</span><span style="color: #007700">, </span><span style="color: #0000BB">100</span><span style="color: #007700">));<br /><br /></span><span style="color: #FF8000">// Output<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 class="example-contents"><p>The above example will output something similar to:</p></div> <div class="mediaobject"> <div class="imageobject"> <img src="images/21009b70229598c6a80eef8b45bf282b-imagelayereffect.png" alt="Output of example : imagelayereffect()" width="100" height="100" /> </div> </div> </div> </div> <div class="refsect1 notes" id="refsect1-function.imagelayereffect-notes"> <h3 class="title">Notes</h3> <blockquote class="note"><p><strong class="note">Note</strong>: <span class="simpara">This function is only available if PHP is compiled with the bundled version of the GD library.</span></p></blockquote> <blockquote class="note"><p><strong class="note">Note</strong>: <span class="simpara">This function requires GD 2.0.1 or later (2.0.28 or later is recommended).</span></p></blockquote> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.imagejpeg.html">imagejpeg</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.imageline.html">imageline</a></div> <div class="up"><a href="ref.image.html">GD and Image Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>