...

View Full Version : Layering Two Images



l33t H4X0R
06-01-2011, 03:58 PM
All i need is some PHP + GD Script which takes two image URLS and Two Coordinates. What I want it to do with those is join the two images at those coordinates.
The effect I would like is for it to take the address of an armour and a sword and make the person (armour) hold the sword

Jinxy
06-02-2011, 05:01 PM
Try this:



<?php
# background image
$image1 = imagecreatefromjpeg('comp-bg.jpg');
imagealphablending($image1, true);

# image to composite
$image2 = imagecreatefromjpeg('comp-2.jpg');
$width = imageSX($image2);
$height = imageSY($image2);

# position your image, replacing 220, 315, with 0, 0,
# will place your image to the top left corner
imagecopy($image1, $image2, 220, 315, 0, 0, $width, $height);

imagecolorallocate($image1, 255, 255, 255);

# output to browser
header("Content-type: image/jpeg");
imagejpeg($image1);

# write image to directory
imagejpeg($image1, "composited.jpg");

# free server memory
imagedestroy($image1);
imagedestroy($image2);
?>


If you can use ImageMagick by the command line, take a look at this:

http://www.lingolinda.com/2008/scripts/IM/ImageMagick.php



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum