Image resizing

images php coding issues or problems here.

Moderators: gesf, Michalio

Post Reply
calvinklein

Hi,

You can use image resizing php scripts like timthumb, imagemagick etc

Goodluck
php web development india
lokanath7

/*---------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;
}
webinfopedia

Hi
Here is one of my article to create thumbnail image from a large with small file size. Read the below article and download example file..
http://www.webinfopedia.com/create-thum ... g-PHP.html

Hope this is what you looking for...
Thank you
mikebright

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.
matthew92

tranktech wrote: Fri May 28, 2021 10:05 pm Use timthumb, imagemagick etc
ImageMagick works great! I definitely second that recommendation.
Post Reply