09-30-2007, 12:05 PM
|
#2 (permalink)
|
|
La Vida es Sueño
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
|
I use the following function, but I wrote it almost a year ago now so it may not be the best way of doing it. You've got to remember though that manipulating images is an intensive task in itself.
PHP Code:
function doResize($szSource, $szDestination, $szExtension, $iResizeWidth, $iResizeHeight) { declare(ticks = 1) { $szExtension = strtolower($szExtension); 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.
|
|
|