Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Images

Image resizing

images php coding issues or problems here.

Moderators: macek, egami, gesf

Image resizing

Postby dhrubajyoti » Sat May 22, 2010 10:25 am

Hi,
Can anyone help me in image resizing. I know its too easy to upload and re-size an image, but the prob comes like - the shape (pixel wise) get reduced, but the size(MB/KB) does not get reduced accordingly...
Any third party or application so that I can use it my site would have helped....

-Regards
Dhrubajyoti
dhrubajyoti
New php-forum User
New php-forum User
 
Posts: 1
Joined: Sat May 22, 2010 10:15 am

Re: Image resizing

Postby calvinklein » Sat Jun 19, 2010 11:00 am

Hi,

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

Goodluck
php web development india
calvinklein
New php-forum User
New php-forum User
 
Posts: 5
Joined: Sat Jun 19, 2010 10:17 am

Re: Image resizing

Postby mayurpimple » Tue Nov 23, 2010 9:44 pm

calvinklein wrote:Hi,

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

Goodluck
php web development india


hi i want resize my image . im woking in greengeeks server. not local server.
any code for that :(
mayurpimple
New php-forum User
New php-forum User
 
Posts: 1
Joined: Tue Nov 23, 2010 9:38 pm

Re: Image resizing

Postby lokanath7 » 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);
$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;
}
lokanath7
New php-forum User
New php-forum User
 
Posts: 139
Joined: Mon Nov 15, 2010 12:11 am

Re: Image resizing

Postby webinfopedia » Fri Jun 10, 2011 4:05 am

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-thumbnail-image-dynamically-using-PHP.html

Hope this is what you looking for...
Thank you
User avatar
webinfopedia
New php-forum User
New php-forum User
 
Posts: 84
Joined: Sat May 21, 2011 10:26 pm


Return to PHP coding => Images

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.