mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-17 21:16:57 +08:00
127 lines
5.8 KiB
HTML
127 lines
5.8 KiB
HTML
<!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 class="docs"><div id="layout">
|
|
<div id="layout-content"><div id="function.imageresolution" class="refentry">
|
|
<div class="refnamediv">
|
|
<h1 class="refname">imageresolution</h1>
|
|
<p class="verinfo">(PHP 7 >= 7.2.0)</p><p class="refpurpose"><span class="refname">imageresolution</span> — <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">resource</span> <code class="parameter">$image</code></span>
|
|
) : <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span></div>
|
|
|
|
<div class="methodsynopsis dc-description">
|
|
<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 class="initializer"> = $res_x</span></span>
|
|
] ) : <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></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">参数</h3>
|
|
<dl>
|
|
|
|
<dt>
|
|
<code class="parameter">image</code></dt>
|
|
|
|
<dd>
|
|
<p class="para">由图象创建函数(例如<span class="function"><a href="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">返回值</h3>
|
|
<p class="para">
|
|
When used as getter (first signature), it returns
|
|
<strong><code>TRUE</code></strong> on success, 或者在失败时返回 <strong><code>FALSE</code></strong>.
|
|
When used as setter (second signature),
|
|
it returns an indexed array of the horizontal and vertical resolution on
|
|
success, 或者在失败时返回 <strong><code>FALSE</code></strong>.
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 examples" id="refsect1-function.imageresolution-examples">
|
|
<h3 class="title">范例</h3>
|
|
<div class="example" id="example-3733">
|
|
<p><strong>Example #1 Setting and getting the resolution of an image</strong></p>
|
|
<div class="example-contents">
|
|
<div class="phpcode"><pre><span style="color: #000000">
|
|
<span style="color: #0000BB"><?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">?></span>
|
|
</span>
|
|
</pre></div>
|
|
</div>
|
|
|
|
<div class="example-contents"><p>以上例程会输出:</p></div>
|
|
<div class="example-contents screen">
|
|
<div class="cdata"><pre>
|
|
Array
|
|
(
|
|
[0] => 200
|
|
[1] => 200
|
|
)
|
|
Array
|
|
(
|
|
[0] => 300
|
|
[1] => 72
|
|
)
|
|
</pre></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</div></div></div></body></html> |