<?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 => 'ja',
  ),
  'this' => 
  array (
    0 => 'function.imagecreate.php',
    1 => 'imagecreate',
    2 => 'パレットを使用する新規画像を作成する',
  ),
  'up' => 
  array (
    0 => 'ref.image.php',
    1 => 'GD および Image 関数',
  ),
  'prev' => 
  array (
    0 => 'function.imagecopyresized.php',
    1 => 'imagecopyresized',
  ),
  'next' => 
  array (
    0 => 'function.imagecreatefromavif.php',
    1 => 'imagecreatefromavif',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'ja',
    'path' => 'reference/image/functions/imagecreate.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.imagecreate" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">imagecreate</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">imagecreate</span> &mdash; <span class="dc-title">パレットを使用する新規画像を作成する</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.imagecreate-description">
  <h3 class="title">説明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>imagecreate</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$width</code></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$height</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">
   <span class="function"><strong>imagecreate()</strong></span> は、
   指定した大きさの空の画像を表す画像 ID を返します。
  </p>
  <p class="para">
   一般に、<span class="function"><strong>imagecreate()</strong></span> よりは
   <span class="function"><a href="function.imagecreatetruecolor.php" class="function">imagecreatetruecolor()</a></span> を使うことを推奨します。
   より高品質な画像処理ができるからです。パレット形式の画像を出力したい場合は、
   <span class="function"><a href="function.imagepng.php" class="function">imagepng()</a></span> や
   <span class="function"><a href="function.imagegif.php" class="function">imagegif()</a></span> で画像を保存する直前に
   <span class="function"><a href="function.imagetruecolortopalette.php" class="function">imagetruecolortopalette()</a></span> を呼ばなければいけません。
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.imagecreate-parameters">
  <h3 class="title">パラメータ</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">width</code></dt>
     <dd>
      <p class="para">
       画像の幅。
      </p>
     </dd>
    
    
     <dt><code class="parameter">height</code></dt>
     <dd>
      <p class="para">
       画像の高さ。
      </p>
     </dd>
    
   </dl>
  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.imagecreate-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.imagecreate-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.imagecreate-examples">
  <h3 class="title">例</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>例1 
     新しい GD 画像ストリームの作成および画像の出力
    </strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />header</span><span style="color: #007700">(</span><span style="color: #DD0000">"Content-Type: image/png"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$im </span><span style="color: #007700">= @</span><span style="color: #0000BB">imagecreate</span><span style="color: #007700">(</span><span style="color: #0000BB">110</span><span style="color: #007700">, </span><span style="color: #0000BB">20</span><span style="color: #007700">)<br />    or die(</span><span style="color: #DD0000">"Cannot Initialize new GD image stream"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$background_color </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">0</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">);<br /></span><span style="color: #0000BB">$text_color </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">233</span><span style="color: #007700">, </span><span style="color: #0000BB">14</span><span style="color: #007700">, </span><span style="color: #0000BB">91</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">imagestring</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">, </span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #0000BB">5</span><span style="color: #007700">, </span><span style="color: #0000BB">5</span><span style="color: #007700">,  </span><span style="color: #DD0000">"A Simple Text String"</span><span style="color: #007700">, </span><span style="color: #0000BB">$text_color</span><span style="color: #007700">);<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">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>上の例の出力は、
たとえば以下のようになります。</p></div>
    <div class="mediaobject">
     
     <div class="imageobject">
      <img src="images/21009b70229598c6a80eef8b45bf282b-imagecreate.png" alt="出力例 : 新しい GD 画像ストリームの作成および画像の出力" width="110" height="25" />
     </div>
    </div>
   </div>
  </p>
 </div>

 <div class="refsect1 seealso" id="refsect1-function.imagecreate-seealso">
  <h3 class="title">参考</h3>
  <ul class="simplelist">
   <li><span class="function"><a href="function.imagecreatetruecolor.php" class="function" rel="rdfs-seeAlso">imagecreatetruecolor()</a> - TrueColor イメージを新規に作成する</span></li>
  </ul>
 </div>

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