<!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>Create a new image from file or URL</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.imagecreatefromxbm.html">imagecreatefromxbm</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.imagecreatetruecolor.html">imagecreatetruecolor</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.imagecreatefromxpm" class="refentry"> <div class="refnamediv"> <h1 class="refname">imagecreatefromxpm</h1> <p class="verinfo">(PHP 4 >= 4.0.1, PHP 5)</p><p class="refpurpose"><span class="refname">imagecreatefromxpm</span> — <span class="dc-title">Create a new image from file or URL</span></p> </div> <div class="refsect1 description" id="refsect1-function.imagecreatefromxpm-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">resource</span> <span class="methodname"><strong>imagecreatefromxpm</strong></span> ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$filename</code></span> )</div> <p class="para rdfs-comment"> <span class="function"><strong>imagecreatefromxpm()</strong></span> returns an image identifier representing the image obtained from the given filename. </p> <div class="tip"><strong class="tip">Tip</strong><p class="simpara">A URL can be used as a filename with this function if the <a href="filesystem.configuration.html#ini.allow-url-fopen" class="link">fopen wrappers</a> have been enabled. See <span class="function"><a href="function.fopen.html" class="function">fopen()</a></span> for more details on how to specify the filename. See the <a href="wrappers.html" class="xref">Supported Protocols and Wrappers</a> for links to information about what abilities the various wrappers have, notes on their usage, and information on any predefined variables they may provide.</p></div> </div> <div class="refsect1 parameters" id="refsect1-function.imagecreatefromxpm-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">filename</code></em></span> <dd> <p class="para"> Path to the XPM image. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.imagecreatefromxpm-returnvalues"> <h3 class="title">Return Values</h3> <p class="para">Returns an image resource identifier on success, <strong><code>FALSE</code></strong> on errors.</p> </div> <div class="refsect1 examples" id="refsect1-function.imagecreatefromxpm-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-3219"> <p><strong>Example #1 Creating an image instance using <span class="function"><strong>imagecreatefromxpm()</strong></span></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">// Check for XPM support<br /></span><span style="color: #007700">if(!(</span><span style="color: #0000BB">imagetypes</span><span style="color: #007700">() & </span><span style="color: #0000BB">IMG_XPM</span><span style="color: #007700">))<br />{<br /> die(</span><span style="color: #DD0000">'Support for xpm was not found!'</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #FF8000">// Create the image instance<br /></span><span style="color: #0000BB">$xpm </span><span style="color: #007700">= </span><span style="color: #0000BB">imagecreatefromxpm</span><span style="color: #007700">(</span><span style="color: #DD0000">'./example.xpm'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Do image operations here<br /><br />// PHP has no support for writing xpm images<br />// so in this case we save the image as a <br />// jpeg file with 100% quality<br /></span><span style="color: #0000BB">imagejpeg</span><span style="color: #007700">(</span><span style="color: #0000BB">$xpm</span><span style="color: #007700">, </span><span style="color: #DD0000">'./example.jpg'</span><span style="color: #007700">, </span><span style="color: #0000BB">100</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">imagedestroy</span><span style="color: #007700">(</span><span style="color: #0000BB">$xpm</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> </div> </p> </div> <div class="refsect1 notes" id="refsect1-function.imagecreatefromxpm-notes"> <h3 class="title">Return Values</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 is not implemented on Windows platforms.</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.imagecreatefromxbm.html">imagecreatefromxbm</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.imagecreatetruecolor.html">imagecreatetruecolor</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>