I'm trying to modify an image using php and GD to basically add a copyright at the bottom when somebody views it.
The idea is to take the original image, add a balck line at the bottom with the white lettering stating the copyright. At the moment it is working great except that it seems the orignial image (a jpg photo) has lost a lot of quality, it looks like its converting it to 255 colours as the colours are all wrong.
Is there a way around this? The server I'm on has GD 1.6 which is pretty old, the only things I've read that might work are functions where version 2.0 or higher is required.
I've asked my hosting company about upgrading but not had a response yet, is there anything that might work in the meantime?
Heres the code:
<?
$pathmain3 = "/usr/local/customer/virtualfp/www.plane-mad.com/photos/$filename.jpg";
$pathmain1 = ImageCreatefromjpeg($pathmain3);
$pathmain4 = "/usr/local/customer/virtualfp/www.plane-mad.com/pictures/pmsm.jpg";
$pathmain2 = ImageCreateFromJPEG($pathmain4);
$height = imagesy($pathmain1);
$width = imagesx($pathmain1);
$string_width2 = 170;
$start = $width-$string_width2;
$heighttotal = $height+15;
$img = ImageCreate($width,$heighttotal);
$black = ImageColorAllocate($img, 0, 0, 0); $white = ImageColorAllocate($img, 255, 255,
255);
$photoinfo = "MyTravel Lite A320 @ Birmingham";
$info = "Photo Copyright Danny Hill | $photoinfo";
ImageFill($img, 0, 0, $black);
ImageString($img, 3, 3, $height, "$info", $white);
imagecopy ($img, $pathmain2, $start, $height, 0, 0, $width, 15);
imagecopy($img, $pathmain1, 0, 0, 0, 0, $width, $height);
Header( "Content-type: image/jpeg");
ImageJPEG($img,'',99);
ImageDestroy($pathmain1);
ImageDestroy($img);
ImageDestroy($pathmain2);
?>
The original image: http://www.plane-mad.com/photos/vz320_bhx-7.jpg
The resulting image: http://www.plane-mad.com/photo_copy.php?filename=vz320_bhx-7
The problem is worse on the grass underneath the aircraft.
Any help would be appreciated.