Improving image quality

I’m using the script below to create thumbnails on the fly. (Its a mix of found and php written by me.)

Is there anyway to improve the quality? The thumbnails are a little soft and there is some color shifting.
As a note, imagemagick isn’t installed on the server which is part of a shared hosting package.

<?php

$max=140;

error_reporting(E_ALL);
ini_set("display_errors", 1); 

// check to see if GD function exist
if(!function_exists('imagecreatetruecolor')) {
    displayError('GD Library Error: imagecreatetruecolor does not exist - please contact your webhost and ask them to install the GD library');
}

define ('CACHE_SIZE', 250);					// number of files to store before clearing cache
define ('CACHE_CLEAR', 5);					// maximum number of files to delete on each cache clear
define ('VERSION', '1.14');					// version number (to force a cache refresh)
define ('DIRECTORY_CACHE', './cache');		// cache directory
define ('DIRECTORY_TEMP', './temp');		// temp directory


// sort out image source
$src = $_GET['src'];
$src=$_SERVER['DOCUMENT_ROOT'].$src;

list($width, $height, $type, $attr) = getimagesize($src);
if ($width>$height && $width > $max ){$perc=($max/$width);}
if ($height>$width && $height > $max ){$perc=($max/$height);}
else { $perc=1; }

  $new_width=intval($width*$perc);
  $new_height=intval($height*$perc);


    $imageResized = imagecreatetruecolor($new_width, $new_height);
    $imageTmp     = imagecreatefromjpeg ($src);
    imagecopyresampled($imageResized, $imageTmp, 0, 0, 0, 0, $new_width, $new_height, $width, $height);

	// Set the content type header - in this case image/jpeg
	header('Content-type: image/jpeg');
	imagejpeg($imageResized,null,75);
?>

This looks pretty cool thanks

Using an unsharp mask filter on the image will improve the thumbnail considerably

Here is a link to php code for this filter

http://vikjavev.no/computing/ump.php

Unfortunately, I tried 100 and it didn’t look any different.

Try increasing the quality parameter in the imagejpeg function:


imagejpeg($imageResized,null,90);