I'm trying to write a script which will rotate an image, and overlay it on another image. It is working, except there are artifacts in the background, where the image has been resized.
An example is here:
http://tsunet.co.uk/php/gd/water.php
My code is:
Code: Select all
<?
$name = "Liz Barton";
$title = "V Festival Aug 09";
$line1 = ""I discovered Sol,";
$line2 = "I've never drunk";
$line3 = "beer before but";
$line4 = "I love this"";
$file = 'blank3.png';
$dim = getimagesize($file);
$imagewidth = $dim[0];
$imageheight = $dim[1];
$image = imagecreatefrompng($file);
$black = imagecolorallocate($image, 0, 0, 0);
$grey = imagecolorallocate($image, 128, 128, 128);
$font = 'ArdleysHand.ttf';
$filename = 'front1.png';
$degrees = 7.5;
$source = imagecreatefrompng($filename);
$rotate = imagerotate($source, $degrees, -1);
imagesavealpha($rotate, true);
imagealphablending($rotate, true);
imagesavealpha($image, true);
imagealphablending($image, true);
imagettftext($image, 12, -10, 160, 310, $black, $font, $name);
imagettftext($image, 12, -10, 155, 330, $black, $font, $title);
imagettftext($image, 12, -10, 150, 360, $black, $font, $line1);
imagettftext($image, 12, -10, 145, 380, $black, $font, $line2);
imagettftext($image, 12, -10, 140, 400, $black, $font, $line3);
imagettftext($image, 12, -10, 140, 420, $black, $font, $line4);
imagecopy($image, $rotate, $dest_x, $dest_y, -11, -28, 350, 275);
header('Content-type: image/png');
imagepng($image);
imagedestroy($image);
?>
Thanks
Terry