Image resizing

/*---------try this and give the arguments correctly and let me know is it working in ur server correctly or not-----*/

function resizeImage($originalImage,$toWidth,$toHeight,$ext){

// Get the original geometry and calculate scales
list($width, $height) = getimagesize($originalImage);
$xscale=$width/$toWidth;
$yscale=$height/$toHeight;

// Recalculate new size with default ratio
if($toWidth > $width && $toHeight > $height)
{
$new_width = $width;
$new_height = $height;
}
else
{
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));
}
}
// Resize the original image
$imageResized = imagecreatetruecolor($toWidth, $toHeight);
$bg=imagecolorallocate ( $imageResized, 255, 255, 255 );
imagefill ( $imageResized, 0, 0, $bg );

switch($ext) {
case 'jpg':
$imageTmp = imagecreatefromjpeg($originalImage);
break;
case 'jpeg':
$imageTmp = imagecreatefromjpeg($originalImage);
break;
case 'png':
$imageTmp = imagecreatefrompng($originalImage);
break;
case 'gif':
$imageTmp = imagecreatefromgif($originalImage);
break;
default:
$err = 1;
//die;
break;
}
imagecopyresampled($imageResized, $imageTmp, ($toWidth-$new_width)/2, ($toHeight-$new_height)/2, 0, 0, $new_width, $new_height, $width, $height);

return $imageResized;
}
 
As previously stated, software development refers to the whole process by which a web application is created from scratch. On the other hand, a web application refers to the solutions developed using web technologies such as HTML, XML, PHP, etc. This means that web developers do the actual writing of the code, while a software developer does the "heavy lifting" of converting the written code into a functional web application. A web developer by https://mlsdev.com/services/custom-software-development will have more experience in programming, while a web developer will have less knowledge in programming, because they rarely write anything themselves.
 
Back
Top