Sophie

Sophie

distrib > Mageia > 7 > i586 > by-pkgid > 2b917e0437961edec048f1d15e2d7449 > files > 4158

php-manual-en-7.2.11-1.mga7.noarch.rpm

<!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>Get or set the resolution of the image</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.imagerectangle.html">imagerectangle</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.imagerotate.html">imagerotate</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.imageresolution" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">imageresolution</h1>
  <p class="verinfo">(PHP 7 &gt;= 7.2.0)</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">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <span class="methodname"><strong>imageresolution</strong></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$image</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$res_x</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$res_y</code></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 none of the optional parameters is given,
   the current resolution is returned as indexed array. If only
   <code class="parameter">res_x</code> is given, the horizontal and vertical resolution
   are set to this value. If both optional parameters are given, 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">Parameters</h3>
  <dl>

   <dt>
<code class="parameter">
image</code></dt>
<dd>
<p class="para">An image resource, returned by one of the image creation functions,
such as <span class="function"><a href="function.imagecreatetruecolor.html" class="function">imagecreatetruecolor()</a></span>.</p></dd>

   
    <dt>
<code class="parameter">res_x</code></dt>

    <dd>

     <p class="para">
      The horizontal resolution in DPI.
     </p>
    </dd>

   
   
    <dt>
<code class="parameter">res_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">Return Values</h3>
  <p class="para">
   When used as getter (that is without the optional parameters), it returns
   <strong><code>TRUE</code></strong> on success,  or <strong><code>FALSE</code></strong> on failure.
   When used as setter (that is with one or both optional parameters given),
   it returns an indexed array of the horizontal and vertical resolution on
   success,  or <strong><code>FALSE</code></strong> on failure.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.imageresolution-examples">
  <h3 class="title">Examples</h3>
  <div class="example" id="example-3840">
   <p><strong>Example #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&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">imagecreatetruecolor</span><span style="color: #007700">(</span><span style="color: #0000BB">100</span><span style="color: #007700">,&nbsp;</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">,&nbsp;</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">,&nbsp;</span><span style="color: #0000BB">300</span><span style="color: #007700">,&nbsp;</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>The above example will output:</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
Array
(
    [0] =&gt; 200
    [1] =&gt; 200
)
Array
(
    [0] =&gt; 300
    [1] =&gt; 72
)
</pre></div>
   </div>
  </div>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.imagerectangle.html">imagerectangle</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.imagerotate.html">imagerotate</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>