<?php include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc'; $TOC = array(); $TOC_DEPRECATED = array(); $PARENTS = array(); include_once dirname(__FILE__) ."/toc/class.imagick.inc"; $setup = array ( 'home' => array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'imagick.thumbnailimage.php', 1 => 'Imagick::thumbnailImage', 2 => 'Changes the size of an image', ), 'up' => array ( 0 => 'class.imagick.php', 1 => 'Imagick', ), 'prev' => array ( 0 => 'imagick.thresholdimage.php', 1 => 'Imagick::thresholdImage', ), 'next' => array ( 0 => 'imagick.tintimage.php', 1 => 'Imagick::tintImage', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/imagick/imagick/thumbnailimage.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?> <div id="imagick.thumbnailimage" class="refentry"> <div class="refnamediv"> <h1 class="refname">Imagick::thumbnailImage</h1> <p class="verinfo">(PECL imagick 2, PECL imagick 3)</p><p class="refpurpose"><span class="refname">Imagick::thumbnailImage</span> — <span class="dc-title">Changes the size of an image</span></p> </div> <div class="refsect1 description" id="refsect1-imagick.thumbnailimage-description"> <h3 class="title">说明</h3> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="methodname"><strong>Imagick::thumbnailImage</strong></span>(<br> <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$columns</code></span>,<br> <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$rows</code></span>,<br> <span class="methodparam"><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span> <code class="parameter">$bestfit</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong></span></span>,<br> <span class="methodparam"><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span> <code class="parameter">$fill</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong></span></span>,<br> <span class="methodparam"><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span> <code class="parameter">$legacy</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong></span></span><br>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div> <p class="para rdfs-comment"> Changes the size of an image to the given dimensions and removes any associated profiles. The goal is to produce small, low cost thumbnail images suited for display on the Web. If <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> is given as a third parameter then columns and rows parameters are used as maximums for each side. Both sides will be scaled down until they match or are smaller than the parameter given for the side. </p> <blockquote class="note"><p><strong class="note">注意</strong>: <span class="simpara"> 参数 <code class="parameter">bestfit</code> 的特性在 Imagick 3.0.0 中已改变。在此版本以前,当目标尺寸设为 400x400 时,原尺寸为 200x150 的图像将不会被改变。自 Imagick 3.0.0 起,源图像将会被放大到 400x300 因为这将更好的适合目标尺寸。当使用参数 <code class="parameter">bestfit</code> 时,必须同时给出宽度和高度。 </span> </p></blockquote> </div> <div class="refsect1 parameters" id="refsect1-imagick.thumbnailimage-parameters"> <h3 class="title">参数</h3> <p class="para"> <dl> <dt><code class="parameter">columns</code></dt> <dd> <p class="para"> Image width </p> </dd> <dt><code class="parameter">rows</code></dt> <dd> <p class="para"> Image height </p> </dd> <dt><code class="parameter">bestfit</code></dt> <dd> <p class="para"> Whether to force maximum values </p> </dd> <dt><code class="parameter">fill</code></dt> <dd> <p class="para"> If the image does not fill the box completely then the box is filled with image's background color. </p> </dd> <dt><code class="parameter">legacy</code></dt> <dd> <p class="para"> Round the smaller dimension down instead to the closest integer. </p> </dd> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-imagick.thumbnailimage-returnvalues"> <h3 class="title">返回值</h3> <p class="para"> 成功时返回 <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>。 </p> </div> <div class="refsect1 errors" id="refsect1-imagick.thumbnailimage-errors"> <h3 class="title">错误/异常</h3> <p class="para"> 错误时抛出 ImagickException。 </p> </div> <div class="refsect1 examples" id="refsect1-imagick.thumbnailimage-examples"> <h3 class="title">示例</h3> <p class="para"> <div class="example" id="example-3108"> <p><strong>示例 #1 <span class="function"><strong>Imagick::thumbnailImage()</strong></span></strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br /></span><span style="color: #007700">function </span><span style="color: #0000BB">thumbnailImage</span><span style="color: #007700">(</span><span style="color: #0000BB">$imagePath</span><span style="color: #007700">) {<br /> </span><span style="color: #0000BB">$imagick </span><span style="color: #007700">= new </span><span style="color: #0000BB">\Imagick</span><span style="color: #007700">(</span><span style="color: #0000BB">realpath</span><span style="color: #007700">(</span><span style="color: #0000BB">$imagePath</span><span style="color: #007700">));<br /> </span><span style="color: #0000BB">$imagick</span><span style="color: #007700">-></span><span style="color: #0000BB">setbackgroundcolor</span><span style="color: #007700">(</span><span style="color: #DD0000">'rgb(64, 64, 64)'</span><span style="color: #007700">);<br /> </span><span style="color: #0000BB">$imagick</span><span style="color: #007700">-></span><span style="color: #0000BB">thumbnailImage</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">, </span><span style="color: #0000BB">true</span><span style="color: #007700">, </span><span style="color: #0000BB">true</span><span style="color: #007700">);<br /> </span><span style="color: #0000BB">header</span><span style="color: #007700">(</span><span style="color: #DD0000">"Content-Type: image/jpg"</span><span style="color: #007700">);<br /> echo </span><span style="color: #0000BB">$imagick</span><span style="color: #007700">-></span><span style="color: #0000BB">getImageBlob</span><span style="color: #007700">();<br />}<br /><br /></span><span style="color: #0000BB">?></span></span></code></div> </div> </div> </p> </div> </div><?php manual_footer($setup); ?>