<?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.imageresolution.php',
    1 => 'imageresolution',
    2 => 'Get or set the resolution of the image',
  ),
  'up' => 
  array (
    0 => 'ref.image.php',
    1 => 'GD 和图像处理 函数',
  ),
  'prev' => 
  array (
    0 => 'function.imagerectangle.php',
    1 => 'imagerectangle',
  ),
  'next' => 
  array (
    0 => 'function.imagerotate.php',
    1 => 'imagerotate',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/image/functions/imageresolution.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.imageresolution" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">imageresolution</h1>
  <p class="verinfo">(PHP 7 &gt;= 7.2.0, PHP 8)</p><p class="refpurpose"><span class="refname">imageresolution</span> &mdash; <span class="dc-title">Get or set the resolution of the image</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.imageresolution-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>imageresolution</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.null.php" class="type null">?</a></span><span class="type"><a href="language.types.integer.php" class="type int">int</a></span></span> <code class="parameter">$resolution_x</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"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.integer.php" class="type int">int</a></span></span> <code class="parameter">$resolution_y</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>): <span class="type"><span class="type"><a href="language.types.array.php" class="type array">array</a></span>|<span class="type"><a href="language.types.singleton.php" class="type true">true</a></span></span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>imageresolution()</strong></span> allows to set and get the resolution of
   an image in DPI (dots per inch). If the optional parameters are <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>,
   the current resolution is returned as an indexed array. If only
   <code class="parameter">resolution_x</code> is not <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>, the horizontal and vertical resolution
   are set to this value. If none of the optional parameters are <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>, the horizontal
   and vertical resolution are set to these values, respectively.
  </p>
  <p class="para">
   The resolution is only used as meta information when images are read from and
   written to formats supporting this kind of information (curently PNG and
   JPEG). It does not affect any drawing operations. The default resolution
   for new images is 96 DPI.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.imageresolution-parameters">
  <h3 class="title">参数</h3>
  <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">resolution_x</code></dt>
    <dd>
     <p class="para">
      The horizontal resolution in DPI.
     </p>
    </dd>
   
   
    <dt><code class="parameter">resolution_y</code></dt>
    <dd>
     <p class="para">
      The vertical resolution in DPI.
     </p>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.imageresolution-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   When used as getter,
   it returns an indexed array of the horizontal and vertical resolution on
   success.
   When used as setter, it always returns <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>.
  </p>
 </div>



 <div class="refsect1 changelog" id="refsect1-function.imageresolution-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>
       <code class="parameter">resolution_x</code> and <code class="parameter">resolution_y</code> are now nullable.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.imageresolution-examples">
  <h3 class="title">示例</h3>
  <div class="example" id="imageresolution.example.basic">
   <p><strong>示例 #1 Setting and getting the resolution of an image</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$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 /></span><span style="color: #0000BB">imageresolution</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">, </span><span style="color: #0000BB">200</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">imageresolution</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">imageresolution</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">, </span><span style="color: #0000BB">300</span><span style="color: #007700">, </span><span style="color: #0000BB">72</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">imageresolution</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="example-contents screen">
<div class="examplescode"><pre class="examplescode">Array
(
    [0] =&gt; 200
    [1] =&gt; 200
)
Array
(
    [0] =&gt; 300
    [1] =&gt; 72
)</pre>
</div>
   </div>
  </div>
 </div>


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