I am getting real bad discolorization on my images resizing them does anyone know a way to fix this.
Here is the before resize image.
http://chris.nelson.students.noctrl.edu/images/cars/1022196909-1.jpg
Here is the after resize image.
http://chris.nelson.students.noctrl.edu/images/cars/1024000096-1.jpg
Here is the script i am using to resize the image.
<?
function resize_jpeg( $image_file_path, $new_image_file_path, $max_width=480, $max_height=1600 )
{
$return_val = 1;
$return_val = ( ($img = ImageCreateFromJPEG ( $image_file_path )) && $return_val == 1 ) ? "1" : "0";
$FullImage_width = imagesx ($img); // Original image width
$FullImage_height = imagesy ($img); // Original image height
// now we check for over-sized images and pare them down
// to the dimensions we need for display purposes
$ratio = ( $FullImage_width > $max_width ) ? (real)($max_width / $FullImage_width) : 1 ;
$new_width = ((int)($FullImage_width * $ratio)); //full-size width
$new_height = ((int)($FullImage_height * $ratio)); //full-size height
//check for images that are still too high
$ratio = ( $new_height > $max_height ) ? (real)($max_height / $new_height) : 1 ;
$new_width = ((int)($new_width * $ratio)); //mid-size width
$new_height = ((int)($new_height * $ratio)); //mid-size height
// --Start Full Creation, Copying--
// now, before we get silly and 'resize' an image that doesn't need it...
if ( $new_width == $FullImage_width && $new_height == $FullImage_height )
copy ( $image_file_path, $new_image_file_path );
$full_id = ImageCreate( $new_width , $new_height ); //create an image
ImageCopyResized( $full_id, $img,
0,0, 0,0, //starting points
$new_width, $new_height,
$FullImage_width, $FullImage_height );
$return_val = ( $full = ImageJPEG( $full_id, $new_image_file_path)
&& $return_val == 1 ) ? "1" : "0";
ImageDestroy( $full_id );
// --End Creation, Copying--
return ($return_val) ? TRUE : FALSE ;
}
?>
I pulled it off another site it looks fine to me.
Any help would be great.
Thanks
Chris