Today i give you a PHP tutorial about how to resize an image using PHP as your web programming language.
function resize_jpg($inputFilename, $new_side){
$imagedata = getimagesize($inputFilename);
$w = $imagedata[0];
$h = $imagedata[1];
if ($h > $w) {
$new_w = ($new_side / $h) * $w;
$new_h = $new_side;
} else {
$new_h = ($new_side / $w) * $h;
$new_w = $new_side;
}
$im2 = ImageCreateTrueColor($new_w, $new_h);
$image = ImageCreateFromJpeg($inputFilename);
imagecopyResampled ($im2, $image, 0, 0, 0, 0, $new_w, $new_h, $imagedata[0], $imagedata[1]);
return $im2;
}
Maybe this image resizing code using PHP is not the best of all but at least, it'll help you to do your job =)
Latest Video
Wednesday, March 5, 2008
PHP Image Resizer
Labels: image resizing php
Posted by ajax tutorial at 9:15 AM
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment