<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.image.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'function.imagecreatefromgd2.php',
    1 => 'imagecreatefromgd2',
    2 => '从 GD2 文件或 URL 新建一图像',
  ),
  'up' => 
  array (
    0 => 'ref.image.php',
    1 => 'GD 和图像处理 函数',
  ),
  'prev' => 
  array (
    0 => 'function.imagecreatefromgd.php',
    1 => 'imagecreatefromgd',
  ),
  'next' => 
  array (
    0 => 'function.imagecreatefromgd2part.php',
    1 => 'imagecreatefromgd2part',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'zh',
    'path' => 'reference/image/functions/imagecreatefromgd2.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.imagecreatefromgd2" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">imagecreatefromgd2</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.7, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">imagecreatefromgd2</span> &mdash; <span class="dc-title">从 GD2 文件或 URL 新建一图像</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.imagecreatefromgd2-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>imagecreatefromgd2</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$filename</code></span>): <span class="type"><span class="type"><a href="class.gdimage.php" class="type GdImage">GdImage</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  <p class="para rdfs-comment">
   从 GD2 文件或 URL 新建一图像。
  </p>
  <div class="tip"><strong class="tip">小技巧</strong><p class="simpara">如已启用<a href="filesystem.configuration.php#ini.allow-url-fopen" class="link">fopen 包装器</a>，在此函数中， URL 可作为文件名。关于如何指定文件名详见 <span class="function"><a href="function.fopen.php" class="function">fopen()</a></span>。各种
wapper 的不同功能请参见 <a href="wrappers.php" class="xref">支持的协议和封装协议</a>，注意其用法及其可提供的预定义变量。</p></div>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.imagecreatefromgd2-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">filename</code></dt>
     <dd>
      <p class="para">
       GD2 图像的路径。
      </p>
     </dd>
    
   </dl>
  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.imagecreatefromgd2-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">成功后返回图象对象,失败后返回 <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>。</p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.imagecreatefromgd2-changelog">
  <h3 class="title">更新日志</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>版本</th>
      <th>说明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.0.0</td>
      <td>
       成功时，此函数现在返回 <span class="classname"><a href="class.gdimage.php" class="classname">GDImage</a></span> 实例，之前返回 <span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span>。
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.imagecreatefromgd2-examples">
  <h3 class="title">示例</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>示例 #1 <span class="function"><strong>imagecreatefromgd2()</strong></span> 示例</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">// 加载 gd2 图像<br /></span><span style="color: #0000BB">$im </span><span style="color: #007700">= </span><span style="color: #0000BB">imagecreatefromgd2</span><span style="color: #007700">(</span><span style="color: #DD0000">'./test.gd2'</span><span style="color: #007700">);<br /><br /><br /></span><span style="color: #FF8000">// 在图像上应用效果。<br />// 在这个例子中，反转图像颜色<br /></span><span style="color: #007700">if(</span><span style="color: #0000BB">function_exists</span><span style="color: #007700">(</span><span style="color: #DD0000">'imagefilter'</span><span style="color: #007700">))<br />{<br />    </span><span style="color: #0000BB">imagefilter</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">, </span><span style="color: #0000BB">IMG_FILTER_NEGATE</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #FF8000">// 保存图像<br /></span><span style="color: #0000BB">imagegd2</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">, </span><span style="color: #DD0000">'./test_updated.gd2'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.imagecreatefromgd2-notes">
  <h3 class="title">注释</h3>
  <div class="warning"><strong class="warning">警告</strong><p class="simpara">The GD
and GD2 image formats are proprietary image formats of libgd. They have to be regarded
<em>obsolete</em>, and should only be used for development and testing
purposes.</p></div>
 </div>


</div><?php manual_footer($setup); ?>