document.write('<div class="php" style="font-family: monospace;"><span style="color: #000000; font-weight: bold;">function</span> image_create_thumb<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$filename</span>, <span style="color: #0000ff;">$width</span>, <span style="color: #0000ff;">$height</span><span style="color: #66cc66;">&#41;</span><br />');
document.write('<span style="color: #66cc66;">&#123;</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; <a target="_blank"&nbsp; href="http://www.php.net/list"><span style="color: #000066;">list</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$image</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;Width&quot;</span><span style="color: #66cc66;">&#93;</span>, <span style="color: #0000ff;">$image</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;Height&quot;</span><span style="color: #66cc66;">&#93;</span>, <span style="color: #0000ff;">$image</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;Type&quot;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span> = <a target="_blank"&nbsp; href="http://www.php.net/getimagesize"><span style="color: #000066;">getimagesize</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$filename</span><span style="color: #66cc66;">&#41;</span>;<br />');
document.write('<br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$image</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;Type&quot;</span><span style="color: #66cc66;">&#93;</span> == IMG_JPG || <span style="color: #0000ff;">$image</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;Type&quot;</span><span style="color: #66cc66;">&#93;</span> == IMG_JPEG<span style="color: #66cc66;">&#41;</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">$im_image</span> = ImageCreateFromJPEG<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$filename</span><span style="color: #66cc66;">&#41;</span>;<br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$image</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;Type&quot;</span><span style="color: #66cc66;">&#93;</span> == IMG_GIF<span style="color: #66cc66;">&#41;</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">$im_image</span> = ImageCreateFromGIF<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$filename</span><span style="color: #66cc66;">&#41;</span>;<br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$image</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;Type&quot;</span><span style="color: #66cc66;">&#93;</span> == IMG_PNG<span style="color: #66cc66;">&#41;</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">$im_image</span> = ImageCreateFromPNG<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$filename</span><span style="color: #66cc66;">&#41;</span>;<br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />');
document.write('<br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$image</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;Width&quot;</span><span style="color: #66cc66;">&#93;</span> &gt; <span style="color: #0000ff;">$image</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;Height&quot;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">$scale</span> = <span style="color: #0000ff;">$width</span> / <span style="color: #0000ff;">$image</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;Width&quot;</span><span style="color: #66cc66;">&#93;</span>;<br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">$thumb_width</span> = <span style="color: #0000ff;">$width</span>;<br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">$thumb_height</span>&nbsp; = <a target="_blank"&nbsp; href="http://www.php.net/floor"><span style="color: #000066;">floor</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$image</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;Height&quot;</span><span style="color: #66cc66;">&#93;</span>*<span style="color: #0000ff;">$scale</span><span style="color: #66cc66;">&#41;</span>;<br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">$scale</span> = <span style="color: #0000ff;">$height</span> / <span style="color: #0000ff;">$image</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;Height&quot;</span><span style="color: #66cc66;">&#93;</span>;<br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">$thumb_height</span> = <span style="color: #0000ff;">$height</span>;<br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">$thumb_width</span>&nbsp; = <a target="_blank"&nbsp; href="http://www.php.net/floor"><span style="color: #000066;">floor</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$image</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;Width&quot;</span><span style="color: #66cc66;">&#93;</span>*<span style="color: #0000ff;">$scale</span><span style="color: #66cc66;">&#41;</span>;<br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />');
document.write('<br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">$im_thumb</span> = @ImageCreateTrueColor<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$thumb_width</span>, <span style="color: #0000ff;">$thumb_height</span><span style="color: #66cc66;">&#41;</span> or <a target="_blank"&nbsp; href="http://www.php.net/die"><span style="color: #000066;">die</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Cannot Initialize new GD image stream&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />');
document.write('<br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; ImageCopyResized<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$im_thumb</span>,<span style="color: #0000ff;">$im_image</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #0000ff;">$thumb_width</span>,<span style="color: #0000ff;">$thumb_height</span>,<span style="color: #0000ff;">$image</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;Width&quot;</span><span style="color: #66cc66;">&#93;</span>,<span style="color: #0000ff;">$image</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;Height&quot;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;<br />');
document.write('<br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; ImageDestroy<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$im_image</span><span style="color: #66cc66;">&#41;</span>;<br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; ImagePNG<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$im_thumb</span>, <span style="color: #0000ff;">$filename</span><span style="color: #66cc66;">&#41;</span>;<br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; ImageDestroy<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$im_thumb</span><span style="color: #66cc66;">&#41;</span>;<br />');
document.write('<br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">true</span>;<br />');
document.write('<span style="color: #66cc66;">&#125;</span><span style="color: #808080; font-style: italic;">//image_create_thumb($filename, $width, $height) </span></div>');
document.write('<br />&nbsp;<br /><div style="font-size: 12px">Brought to you by the community at <a href="http://www.bytemycode.com/snippets/snippet/53/1/" target="_blank">byteMyCode</a>.</div>');
