<!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>Scale an image using the given new width and height</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.imagesavealpha.html">imagesavealpha</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.imagesetbrush.html">imagesetbrush</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.imagescale" class="refentry"> <div class="refnamediv"> <h1 class="refname">imagescale</h1> <p class="verinfo">(PHP 5 >= 5.5.0, PHP 7)</p><p class="refpurpose"><span class="refname">imagescale</span> — <span class="dc-title">Scale an image using the given new width and height</span></p> </div> <div class="refsect1 description" id="refsect1-function.imagescale-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">resource</span> <span class="methodname"><strong>imagescale</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">$new_width</code></span> [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$new_height</code><span class="initializer"> = -1</span></span> [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$mode</code><span class="initializer"> = IMG_BILINEAR_FIXED</span></span> ]] )</div> <p class="para rdfs-comment"> <span class="function"><strong>imagescale()</strong></span> scales an image using the given interpolation algorithm. </p> </div> <div class="refsect1 parameters" id="refsect1-function.imagescale-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">new_width</code></dt> <dd> <p class="para"> The width to scale the image to. </p> </dd> <dt> <code class="parameter">new_height</code></dt> <dd> <p class="para"> The height to scale the image to. If omitted or negative, the aspect ratio will be preserved. </p> <div class="caution"><strong class="caution">Caution</strong> <p class="para"> You should always provide the height if using PHP 5.5.18 or earlier, or PHP 5.6.2 or earlier, as the aspect ratio calculation was incorrect. </p> </div> </dd> <dt> <code class="parameter">mode</code></dt> <dd> <p class="para"> One of <strong><code>IMG_NEAREST_NEIGHBOUR</code></strong>, <strong><code>IMG_BILINEAR_FIXED</code></strong>, <strong><code>IMG_BICUBIC</code></strong>, <strong><code>IMG_BICUBIC_FIXED</code></strong> or anything else (will use two pass). <blockquote class="note"><p><strong class="note">Note</strong>: <span class="simpara"> <strong><code>IMG_WEIGHTED4</code></strong> is not yet supported. </span> </p></blockquote> </p> </dd> </dl> </div> <div class="refsect1 returnvalues" id="refsect1-function.imagescale-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Return the scaled image resource on success or <strong><code>FALSE</code></strong> on failure. </p> </div> <div class="refsect1 changelog" id="refsect1-function.imagescale-changelog"> <h3 class="title">Changelog</h3> <p class="para"> <table class="doctable informaltable"> <thead> <tr> <th>Version</th> <th>Description</th> </tr> </thead> <tbody class="tbody"> <tr> <td>5.5.19/5.6.3</td> <td> The calculation of the height if <code class="parameter">new_height</code> was negative or omitted was fixed; prior to these versions, the aspect ratio was not maintained correctly. </td> </tr> </tbody> </table> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.imagesavealpha.html">imagesavealpha</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.imagesetbrush.html">imagesetbrush</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>