Image resizing

images php coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply

Sat Jun 19, 2010 11:00 am


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

php web development india
php-forum Fan User
php-forum Fan User
Posts: 139
Joined: Mon Nov 15, 2010 12:11 am

Wed Nov 24, 2010 12:53 am

/*---------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);

// Recalculate new size with default ratio
if($toWidth > $width && $toHeight > $height)
$new_width = $width;
$new_height = $height;
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);
case 'jpeg':
$imageTmp = imagecreatefromjpeg($originalImage);
case 'png':
$imageTmp = imagecreatefrompng($originalImage);
case 'gif':
$imageTmp = imagecreatefromgif($originalImage);
$err = 1;
imagecopyresampled($imageResized, $imageTmp, ($toWidth-$new_width)/2, ($toHeight-$new_height)/2, 0, 0, $new_width, $new_height, $width, $height);

return $imageResized;
User avatar
php-forum Fan User
php-forum Fan User
Posts: 84
Joined: Sat May 21, 2011 10:26 pm

Fri Jun 10, 2011 4:05 am

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.. ... g-PHP.html

Hope this is what you looking for...
Thank you
New php-forum User
New php-forum User
Posts: 1
Joined: Fri May 28, 2021 10:02 pm

Fri May 28, 2021 10:05 pm

Use timthumb, imagemagick etc

Web Development Company in India
New php-forum User
New php-forum User
Posts: 3
Joined: Thu Feb 18, 2021 6:10 am
Location: USA

Thu Sep 16, 2021 4:26 am

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 will have more experience in programming, while a web developer will have less knowledge in programming, because they rarely write anything themselves.
Post Reply