document.write('<div class="c" style="font-family: monospace;"><br />');
document.write('&nbsp;<span style="color: #000000; font-weight: bold;">function</span> resizeImage<span style="color: #66cc66;">&#40;</span>$file,$scale=<span style="color: #ff0000;">&quot;&quot;</span>,$width=<span style="color: #ff0000;">&quot;&quot;</span>,$height=<span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">&#41;</span><br />');
document.write('&nbsp;<span style="color: #66cc66;">&#123;</span><br />');
document.write('&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">// If they wish to scale the image.</span><br />');
document.write('&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>isset<span style="color: #66cc66;">&#40;</span>$scale<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><br />');
document.write('&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#123;</span><br />');
document.write('&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">// Create our image object from the image.</span><br />');
document.write('&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;$fullImage = imagecreatefromjpeg<span style="color: #66cc66;">&#40;</span>$file<span style="color: #66cc66;">&#41;</span>;<br />');
document.write('&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">// Get the image size, used in calculations later.</span><br />');
document.write('&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;$fullSize = getimagesize<span style="color: #66cc66;">&#40;</span>$file<span style="color: #66cc66;">&#41;</span>;<br />');
document.write('&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">// If there is NOT a thumbnail for this image, make one.</span><br />');
document.write('&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>!file_exists<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;tn_&quot;</span>.$file<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><br />');
document.write('&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#123;</span><br />');
document.write('&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">// Create our thumbnail size, so we can resize to this, and save it.</span><br />');
document.write('&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;$tnImage = imagecreatetruecolor<span style="color: #66cc66;">&#40;</span>$fullSize<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>/$scale, $fullSize<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>/$scale<span style="color: #66cc66;">&#41;</span>;<br />');
document.write('&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">// Resize the image.</span><br />');
document.write('&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;imagecopyresampled<span style="color: #66cc66;">&#40;</span>$tnImage,$fullImage,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,$fullSize<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>/$scale,$fullSize<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>/$scale,$fullSize<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>,$fullSize<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;<br />');
document.write('&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">// Create a new image thumbnail.</span><br />');
document.write('&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;imagejpeg<span style="color: #66cc66;">&#40;</span>$tnImage, <span style="color: #ff0000;">&quot;tn_&quot;</span>.$file<span style="color: #66cc66;">&#41;</span>;<br />');
document.write('&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<br />');
document.write('&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">// Clean Up.</span><br />');
document.write('&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;imagedestroy<span style="color: #66cc66;">&#40;</span>$fullImage<span style="color: #66cc66;">&#41;</span>;<br />');
document.write('&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;imagedestroy<span style="color: #66cc66;">&#40;</span>$tnImage<span style="color: #66cc66;">&#41;</span>;<br />');
document.write('&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">// Return our new image.</span><br />');
document.write('&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #b1b100;">return</span> <span style="color: #ff0000;">&quot;tn_&quot;</span>.$file;<br />');
document.write('&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span><br />');
document.write('&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">// If there is a thumbnail file, lets just load it.&nbsp; &nbsp; </span><br />');
document.write('&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #b1b100;">else</span><br />');
document.write('&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #b1b100;">return</span> <span style="color: #ff0000;">&quot;tn_&quot;</span>.$file;<br />');
document.write('&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span><br />');
document.write('&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">// If they want to force whatever size they want.</span><br />');
document.write('&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;elseif <span style="color: #66cc66;">&#40;</span>isset<span style="color: #66cc66;">&#40;</span>$width<span style="color: #66cc66;">&#41;</span> &amp;&amp; isset<span style="color: #66cc66;">&#40;</span>$height<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><br />');
document.write('&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#123;</span><br />');
document.write('&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #b1b100;">return</span> <span style="color: #ff0000;">&quot;tn_&quot;</span>.$file;<br />');
document.write('&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span><br />');
document.write('&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #b1b100;">else</span><br />');
document.write('&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#123;</span><br />');
document.write('&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">false</span>;<br />');
document.write('&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span><br />');
document.write('&nbsp;<span style="color: #66cc66;">&#125;</span><br />');
document.write('&nbsp;</div>');
document.write('As im just looking over the code, it doesnt look like the force size works, i will revise this when i get a chance. ');
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/624/1/" target="_blank">byteMyCode</a>.</div>');
