Hi, i've got a headache! i'm a ASP person, ive used ASPJPEG in the past, now i have to do the same thing but in PHP...
if for expamle i have an image displayed on a page as below:
<img src="<?php echo $imageDetails['imagePath']; ?>" <?php echo $imageDetails['attr'];?>/>
and i want to dynamically display that picture as a thumbnail of the original lets say, i could use this right:
<?php
header('Content-type: image/jpeg');
//$myimage = resizeImage('filename', 'newwidthmax', 'newheightmax');
$myimage = resizeImage('test.jpg', '150', '120');
print $myimage;
function resizeImage($filename, $newwidth, $newheight){
list($width, $height) = getimagesize($filename);
if($width > $height && $newheight < $height){
$newheight = $height / ($width / $newwidth);
} else if ($width < $height && $newwidth < $width) {
$newwidth = $width / ($height / $newheight);
} else {
$newwidth = $width;
$newheight = $height;
}
$thumb = imagecreatetruecolor($newwidth, $newheight);
$source = imagecreatefromjpeg($filename);
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
return imagejpeg($thumb);
}
?>
BUT!
How do I get the dynamic image to work with the script?
$myimage = resizeImage('test.jpg', '150', '120');
needs to be this kinda thing
$myimage = resizeImage('COLOR=orangered & ($imageDetails['attr']);[/COLOR]', '150', '120');