PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Sun May 27, 2018 6:38 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Tue Sep 08, 2009 7:35 am 
Offline
Forum Newbie

Joined: Tue Sep 08, 2009 7:32 am
Posts: 2
Hi,

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:

Syntax: [ Download ] [ Hide ]
 
<?
 
$name               = "Liz Barton";
$title              = "V Festival Aug 09";
$line1              = "&#34;I discovered Sol,";
$line2              = "I've never drunk";
$line3              = "beer before but";
$line4              = "I love this&#34;";
$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);
?>
 


Any ideas on how I can fix this? I've been trying different things for a day now. Any help would be much appreciated.

Thanks

Terry


Top
 Profile  
 
PostPosted: Tue Sep 08, 2009 9:14 am 
Offline
Forum Newbie

Joined: Tue Sep 08, 2009 7:32 am
Posts: 2
I've worked out that the black bars are coming from imagecopy(). They are filling the area left behind when I offset the position of my rotated image.

As far as I can see, imagecolortransparent() won't work with imagecopy(), but I'm struggling to get a transparent area behind the postcard with imagecopymerge().


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group