Voting

: three minus two?
(Example: nine)

The Note You're Voting On

guru_boy87 at hotmail dot com
15 years ago
Function to resize an image.

<?php
function resizeImage($originalImage,$toWidth,$toHeight)
{

list(
$width, $height) = getimagesize($originalImage);
$xscale=$width/$toWidth;
$yscale=$height/$toHeight;

if (
$yscale>$xscale){
$new_width = round($width * (1/$yscale));
$new_height = round($height * (1/$yscale));
}
else {
$new_width = round($width * (1/$xscale));
$new_height = round($height * (1/$xscale));
}


$imageResized = imagecreatetruecolor($new_width, $new_height);
$imageTmp = imagecreatefromjpeg ($originalImage);
imagecopyresampled($imageResized, $imageTmp, 0, 0, 0, 0, $new_width, $new_height, $width, $height);

return
$imageResized;


}
?>

<< Back to user notes page

To Top