Jump to content

Help merging two images


Krisando

Recommended Posts

Basically I am merging two images, the image merging with it is larger then the source image.

I'm also getting a black line at the top. =\

 

I'm not quite sure how to merge images so any help would be much appreciated.

<?PHP
   $dest = imagecreatefrompng('http://f.imagehost.org/0548/online.png');
   $src = imagecreatefrompng('http://f.imagehost.org/0009/stats.png');

   imagecopymerge($dest, $src, 0, 10, 0, 0, 170, 108, 75);

   // Output and free from memory
   header('Content-Type: image/png');
   imagepng($dest);

   imagedestroy($dest);
   imagedestroy($src);
   //
?>

To see this script in action http://frozenstarfire.com/read.php.

This is for non-profit purposes and has nothing to do with the frozenstarfire.com website, just using as webspace. :)

 

Thanks guys, any help understanding this would be great!

Link to comment
https://forums.phpfreaks.com/topic/189092-help-merging-two-images/
Share on other sites

It wont let me edit the post so new code:

<?PHP
   $dest = ImageCreate(170, 130);
   $status = imagecreatefrompng('online.png');
   $stats = imagecreatefrompng('stats.png');

   imagecopy($dest, $status, 0, 0, 0, 0, 170, 30);
   imagecopy($dest, $stats, 1, 21, 1, 0, 168, 108);

   // Output and free from memory
   header('Content-Type: image/png');
   imagepng($dest);

   imagedestroy($dest);
   imagedestroy($status);
   imagedestroy($stats);
   //
?>

I have managed to merge two images of different sizes, although it looks ratough it looks rather distorted. The black line has gone when I replaced "imagecopymerge()" with "imagecopy()", likely an alpha channel bug.

 

I have a strange white line on the top of the bottom image attached, the thick white like you can see overlapping in http://frozenstarfire.com/read.php, I have no idea what is causing this. At the same time I am trying to write text ontop some how. Quite stuck.

Okay, I had to make the bottom part a gif to show transparency :shrug:.

<?PHP
   $dest = ImageCreate(170, 130);
   $status = imagecreatefrompng('online.png');
   $stats = imagecreatefromgif('stats.gif');

   imagecopy($dest, $status, 0, 0, 0, 0, 170, 30);
   imagecopy($dest, $stats, 1, 21, 1, 0, 168, 108);

   // Output and free from memory
   header('Content-Type: image/png');
   imagepng($dest);

   imagedestroy($dest);
   imagedestroy($status);
   imagedestroy($stats);
   //

I'm not sure how to link "imagecreatefrompng('online.png');" the 'online.php' part to a url, so that would be a great help.

I also have no idea how to draw text onto the image, like an overlay. =\

 

I may have to somehow merge a text image onto this image? Or draw text straight on.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.