Forum Moderators: coopster
I am using following function to resize an image based on a specific ratio
function imageResize($width, $height, $target) {
if ($width > $height) {
$percentage = ($target / $width);
}
else {
$percentage = ($target / $height);
}
$width = round($width * $percentage);
$height = round($height * $percentage);
return "width=\"$width\" height=\"$height\"";
}
but this doesnt reduce the size of the image e.g if an image is 400 x 500 and its size is 400 KB, my function will reduce its dimensions but its size remain same 400 KB .. so half of the job is done..
can anyone help please or is there any other function that not only reduce dimensions but also the size of the image?
thanks
Your best bet is to reduce them before you put them on the server, or if you are allow user uploads or something like that, then you can use php's image functions [us3.php.net] to resize it on upload, and then just display the resized image.
thanks
I think if you resize the uploaded image to an average size of all the images sizes that you'll need, you can then resize them like you did in your previous post making the image larger or smaller depending on what you need.