10-17-2008, 01:07 AM
|
#12 (permalink)
|
|
La Vida es Sueño
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
|
You would drop it into a function. However, you may use my function in which I use to resize the images. I'm not saying mine is better, as it's been a while since I wrote it, but I know how it works  !
You would call it like so:
php Code:
image_resize('left_2405181707586.jpg', 'left_2405181707586-resized.jpg', 400, 400);
The function:
php Code:
function image_resize ($szSource, $szDestination, $iResizeWidth, $iResizeHeight){ declare (ticks = 1) { $szExtension = pathinfo($szSource, PATHINFO_EXTENSION ); switch($szExtension) { case('jpg'): $pSource = imagecreatefromjpeg ($szSource); break; case('jpeg'): $pSource = imagecreatefromjpeg ($szSource); break; case('gif'): $pSource = imagecreatefromgif ($szSource); break; case('wbmp'): $pSource = imagecreatefromwbmp ($szSource); break; case('png'): $pSource = imagecreatefrompng ($szSource); break; } $pResized = imagecreatetruecolor ($iResizeWidth, $iResizeHeight); list($iWidth, $iHeight) = getimagesize($szSource); if(!imagecopyresampled ($pResized, $pSource, 0, 0, 0, 0, $iResizeWidth, $iResizeHeight, $iWidth, $iHeight)) { return false; } switch($szExtension) { case('jpg'): $pResult = imagejpeg ($pResized, $szDestination, 100); break; case('jpeg'): $pResult = imagejpeg ($pResized, $szDestination, 100); break; case('gif'): $pResult = imagegif ($pResized, $szDestination); break; case('wbmp'): $pResult = imagewbmp ($pResized, $szDestination); break; case('png'): $pResult = imagepng ($pResized, $szDestination); break; } if($pResult) { return true; } return false; }}
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
|
|
|