<?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.imagewebp.php',
    1 => 'imagewebp',
    2 => 'WebP 画像をブラウザあるいはファイルに出力する',
  ),
  'up' => 
  array (
    0 => 'ref.image.php',
    1 => 'GD および Image 関数',
  ),
  'prev' => 
  array (
    0 => 'function.imagewbmp.php',
    1 => 'imagewbmp',
  ),
  'next' => 
  array (
    0 => 'function.imagexbm.php',
    1 => 'imagexbm',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'ja',
    'path' => 'reference/image/functions/imagewebp.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.imagewebp" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">imagewebp</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.4.0, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">imagewebp</span> &mdash; <span class="dc-title">WebP 画像をブラウザあるいはファイルに出力する</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.imagewebp-description">
  <h3 class="title">説明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>imagewebp</strong></span>(<span class="methodparam"><span class="type"><a href="class.gdimage.php" class="type GdImage">GdImage</a></span> <code class="parameter">$image</code></span>, <span class="methodparam"><span class="type"><span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span>|<span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.null.php" class="type null">null</a></span></span> <code class="parameter">$file</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$quality</code><span class="initializer"> = -1</span></span>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="para rdfs-comment">
   指定した <code class="parameter">image</code> を、WebP 形式で出力あるいは保存します。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.imagewebp-parameters">
  <h3 class="title">パラメータ</h3>
  <p class="para">
   <dl>
    <dt><code class="parameter">image</code></dt><dd><p class="para"><span class="function"><a href="function.imagecreatetruecolor.php" class="function">imagecreatetruecolor()</a></span>のような画像作成関数が返す <span class="classname"><a href="class.gdimage.php" class="classname">GdImage</a></span> オブジェクト。</p></dd>
    
     <dt><code class="parameter">file</code></dt>
     <dd>
      <p class="para">ファイル保存先のパスあるいはオープン中のリソース (この関数が値を戻した後で自動的にクローズされます)。省略したり <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> を設定したりした場合は、画像ストリームを直接出力します。</p>
     </dd>
    
    
     <dt><code class="parameter">quality</code></dt>
     <dd>
      <p class="para">
       <code class="parameter">quality</code> には、0 (品質は最低で、
       ファイルサイズが小さくなる) から 100 (品質が最高で、ファイルサイズは大きくなる)
       までの値を指定します。
       <code class="literal">-1</code> を指定すると、
       デフォルト値 <code class="literal">80</code> を使います。
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.imagewebp-returnvalues">
  <h3 class="title">戻り値</h3>
  <p class="para">
   成功した場合に <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> を、失敗した場合に <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> を返します。
  </p>
  <div class="caution"><strong class="caution">警告</strong><p class="simpara">しかしながら、libgd がイメージの出力に失敗した場合、この関数は <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> を返します。</p></div>
 </div>


 <div class="refsect1 errors" id="refsect1-function.imagewebp-errors">
  <h3 class="title">エラー / 例外</h3>
  <p class="simpara">
   <code class="parameter">quality</code> が不正の場合、 <span class="classname"><a href="class.valueerror.php" class="classname">ValueError</a></span> をスローします。
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.imagewebp-changelog">
  <h3 class="title">変更履歴</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>バージョン</th>
      <th>説明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.4.0</td>
      <td>
       <code class="parameter">quality</code> が不正の場合、 <span class="classname"><a href="class.valueerror.php" class="classname">ValueError</a></span> をスローするようになりました。
      </td>
     </tr>

     <tr>
 <td>8.0.0</td>
 <td>
  <code class="parameter">image</code> は、
  <span class="classname"><a href="class.gdimage.php" class="classname">GdImage</a></span>
  クラスのインスタンスを期待するようになりました。
  これより前のバージョンでは、有効な <code class="literal">gd</code> <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.imagewebp-examples">
  <h3 class="title">例</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>例1 WebP ファイルの保存</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">// 空の画像を作成し、テキストを追加します<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">120</span><span style="color: #007700">, </span><span style="color: #0000BB">20</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 /><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">'WebP with PHP'</span><span style="color: #007700">, </span><span style="color: #0000BB">$text_color</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// 画像を保存します<br /></span><span style="color: #0000BB">imagewebp</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">, </span><span style="color: #DD0000">'php.webp'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

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

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