<!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>Changes the size of an image</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="imagick.thresholdimage.html">Imagick::thresholdImage</a></div> <div class="next" style="text-align: right; float: right;"><a href="imagick.tintimage.html">Imagick::tintImage</a></div> <div class="up"><a href="class.imagick.html">Imagick</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="imagick.thumbnailimage" class="refentry"> <div class="refnamediv"> <h1 class="refname">Imagick::thumbnailImage</h1> <p class="verinfo">(PECL imagick 2.0.0)</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">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">bool</span> <span class="methodname"><strong>Imagick::thumbnailImage</strong></span> ( <span class="methodparam"><span class="type">int</span> <code class="parameter">$columns</code></span> , <span class="methodparam"><span class="type">int</span> <code class="parameter">$rows</code></span> [, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$bestfit</code><span class="initializer"> = <strong><code>FALSE</code></strong></span></span> [, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$fill</code><span class="initializer"> = <strong><code>FALSE</code></strong></span></span> [, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$legacy</code><span class="initializer"> = <strong><code>FALSE</code></strong></span></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>TRUE</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">Note</strong>: <span class="simpara"> The behavior of the parameter <code class="parameter">bestfit</code> changed in Imagick 3.0.0. Before this version given dimensions 400x400 an image of dimensions 200x150 would be left untouched. In Imagick 3.0.0 and later the image would be scaled up to size 400x300 as this is the "best fit" for the given dimensions. If <code class="parameter">bestfit</code> parameter is used both width and height must be given. </span> </p></blockquote> </div> <div class="refsect1 parameters" id="refsect1-imagick.thumbnailimage-parameters"> <h3 class="title">Parameters</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> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-imagick.thumbnailimage-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns <strong><code>TRUE</code></strong> on success. </p> </div> <div class="refsect1 errors" id="refsect1-imagick.thumbnailimage-errors"> <h3 class="title">Errors/Exceptions</h3> <p class="para"> Throws ImagickException on error. </p> </div> <div class="refsect1 examples" id="refsect1-imagick.thumbnailimage-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-4046"> <p><strong>Example #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><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="imagick.thresholdimage.html">Imagick::thresholdImage</a></div> <div class="next" style="text-align: right; float: right;"><a href="imagick.tintimage.html">Imagick::tintImage</a></div> <div class="up"><a href="class.imagick.html">Imagick</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>