Jump to content

Image quality concerns


DapperDanMan

Recommended Posts

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/manual/en/function.imagecopyresized.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
Link to comment
Share on other sites

***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) [snapback]379820[/snapback][/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/manual/en/function.imagecopyresized.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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.