954,597 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

php image resize quality

I try to use PHP GD library to resize image to thumbnail size, however I found the small converted image has bad quality(distorted color), how can I improve the image quality by using PHP GD library:

$first=imagecreatefromjpeg($uploadfile); 
define(MAX_WIDTH, 180);
define(MAX_HEIGHT, 135);
$width = imagesx($first);
$height = imagesy($first);
$scale = min(MAX_WIDTH/$width, MAX_HEIGHT/$height);
$new_width = floor($scale*$width);
$new_height = floor($scale*$height);
$second=imagecreate($new_width, $new_height);
imagecopyresized($second,$first,0,0,0,0,$new_width,$new_height,$width,$height);
 imagejpeg($second,$v_thumbnailfile);


Thanks for any response.

michael123
Junior Poster in Training
94 posts since Jun 2005
Reputation Points: 10
Solved Threads: 0
 

Can anyone answer my question?

michael123
Junior Poster in Training
94 posts since Jun 2005
Reputation Points: 10
Solved Threads: 0
 

imagejpeg()
function can have 3rd parameter for quality
so use it as
imagejpeg($second,$v_thumbnailfile, 100);

I try to use PHP GD library to resize image to thumbnail size, however I found the small converted image has bad quality(distorted color), how can I improve the image quality by using PHP GD library:

$first=imagecreatefromjpeg($uploadfile); 
define(MAX_WIDTH, 180);
define(MAX_HEIGHT, 135);
$width = imagesx($first);
$height = imagesy($first);
$scale = min(MAX_WIDTH/$width, MAX_HEIGHT/$height);
$new_width = floor($scale*$width);
$new_height = floor($scale*$height);
$second=imagecreate($new_width, $new_height);
imagecopyresized($second,$first,0,0,0,0,$new_width,$new_height,$width,$height);
 imagejpeg($second,$v_thumbnailfile);

Thanks for any response.

fahad.mahmood
Newbie Poster
1 post since Mar 2010
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You