Jump to content


Photo

Image quality concerns


  • Please log in to reply
1 reply to this topic

#1 DapperDanMan

DapperDanMan
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 04 June 2006 - 08:37 AM

I am coming across an issue with resizing images using GD. I notice that they are not very clean. Here is an example:
GD Resizing:
[img src=\"http://oillampstudio.com/element/d_dade/mahsaiid01_jm_tb.jpg\" border=\"0\" alt=\"IPB Image\" /]
Photoshop Resizing:
[img src=\"http://oillampstudio.com/element/d_dade/mahsaiid01_jm200.jpg\" border=\"0\" alt=\"IPB Image\" /]

I am attaching the code (please, I am new to php, so don't yell at me for poor code, please just enlighten me). I am using "imagecreatetruecolor()" which I thought improved image quality as per php.net's snippet (http://us2.php.net/m...copyresized.php). I have heard of some plugin thing called magic-something? Is whatever this plugin is called the only way to get good looking resized images?

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<?php

$source_image = $_GET['img_folder'] .$_GET['img_name'];
$filename = eregi_replace ('.jpg', '_tb.jpg', $source_image);
echo "$source_image<br />";
echo "$filename<br />";

$im = ImageCreateFromJpeg ($source_image);
if (!$im){
echo "Could not generate image";
exit;
}
//header ('Content-type: image/jpeg');
$image_width = ImageSX($im);
$image_height = ImageSY($im);
$max = 200;

echo "Width is: $image_width, Height is: $image_height";
if ($image_width >= $image_height) {
$prop = ($image_width / $max);
}
else if ($image_height >= $image_width) {
$prop = ($image_height / $max);
}
echo" <br /> A proportional reduction would be at: $prop";

$new_width = ($image_width / $prop);
$new_height = ($image_height / $prop);

echo "<br /> The new size of the image will be: $new_width wide by $new_height tall.<br>";

$thumb = imagecreatetruecolor($new_width, $new_height);

imagecopyresized($thumb, $im, 0, 0, 0, 0, $new_width, $new_height, $image_width, $image_height);

imagejpeg($thumb, $filename);

imagedestroy($thumb);

?>[/quote]

Any help would be very much appreciated.

Thank you,

DDM
[a href="http://www.brierrowstudio.com" target="_blank"]http://www.brierrowstudio.com[/a]

#2 DapperDanMan

DapperDanMan
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 04 June 2006 - 08:55 AM

***SOLVED (I think)***

I changed "imagecopyresized" to "imagecopyresampled" and it appears to make the images cleaner when resizing. However, I will still take critiques on my code and if any of you have an even better way to make images look nice, please post it here so that we all can learn.

Thank you,

DDM




[!--quoteo(post=379820:date=Jun 4 2006, 03:37 AM:name=DapperDanMan)--][div class=\'quotetop\']QUOTE(DapperDanMan @ Jun 4 2006, 03:37 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
I am coming across an issue with resizing images using GD. I notice that they are not very clean. Here is an example:
GD Resizing:
[img src=\"http://oillampstudio.com/element/d_dade/mahsaiid01_jm_tb.jpg\" border=\"0\" alt=\"IPB Image\" /]
Photoshop Resizing:
[img src=\"http://oillampstudio.com/element/d_dade/mahsaiid01_jm200.jpg\" border=\"0\" alt=\"IPB Image\" /]

I am attaching the code (please, I am new to php, so don't yell at me for poor code, please just enlighten me). I am using "imagecreatetruecolor()" which I thought improved image quality as per php.net's snippet (http://us2.php.net/m...copyresized.php). I have heard of some plugin thing called magic-something? Is whatever this plugin is called the only way to get good looking resized images?
Any help would be very much appreciated.

Thank you,

DDM
[/quote]

[a href="http://www.brierrowstudio.com" target="_blank"]http://www.brierrowstudio.com[/a]




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users