Well I am using the following code to take any old image into a 160x120 thumbnail, the problem is if there is overflow the background is always black. I've been snooping around the PHP docs but none of these functions seem to have any kind of color parameters. Any ideas or pointers would be great!
$original = 'original_image.jpg';
$thumbnail = 'output_thumbnail.jpg';
list($width,$height) = getimagesize($original);
$width_ratio = 160 / $width;
if ($height * $width_ratio <= 120)
{
$adjusted_width = 160;
$adjusted_height = $height * $width_ratio;
}
else
{
$height_ratio = 120 / $height;
$adjusted_width = $width * $height_ratio;
$adjusted_height = 120;
}
$image_p = imagecreatetruecolor(160,120);
$image = imagecreatefromjpeg($original);
imagecopyresampled($image_p,$image,ceil((160 - $adjusted_width) / 2),ceil((120 - $adjusted_height) / 2),0,0,ceil($adjusted_width),ceil($adjusted_height),$width,$height);
imagejpeg($image_p,$thumbnail,100);
Also if you're unclear what I mean, take this image and consider that it was originally just red text on a white background