Ollie
{ MODERATOR }
posts: 8
last: 26-Mar-2008
TITLE: Merge 2 image files together
DESCRIPTION: A small function i coded when i needed to tile 2 images together side-by-side into 1 image
Submitted: 23-Nov-2007 23:10:38 ( 1yrs 6w 3d 11h ago ) Language: PHP (*.php *.php4 *.php5 *.phtml)
Views: 367 Lines of Code: 31 LINES
Rating:
rate: star1
star2
star3
star4
star5
dstar1
dstar2
dstar3
dstar4
dstar5  ( rated! )
  { 0.00 / 5 }
Difficulty: Beginner
Bookmark
/* Author: 
   Date: 20-11-2007
   Filename: 
   Description: 
   History: 
*/


// CODE  
$imgA = imagecreatefromjpeg("./images/manga.jpg");
$imgB = imagecreatefromjpeg("./images/manga.jpg");

mergepages($imgA,$imgB);

function mergepages($imgA, $imgB){

	// The actual processing
	$canvas = imagecreatetruecolor(imagesx($imgA)+imagesx($imgB),imagesy($imgA));
	imagecopy($canvas,$imgA,0,0,0,0,imagesx($imgA),imagesy($imgA));
	imagecopy($canvas,$imgB,imagesx($imgA),0,0,0,imagesx($imgB),imagesy($imgB));

	// Do whatever you want with the data.
	header('Content-type: image/jpeg');
	imagejpeg($canvas);

	// Clean up
	imagedestroy($imgA);
	imagedestroy($imgB);
	imagedestroy($canvas);

}