PDA

View Full Version : GD Library Image - Insert External Image


TH.Sharplet
10-14-2007, 09:07 PM
Hello,

I have the following code, that creates an image of a rectangle. Can an external image be inserted into my image/code?

<?php
$image = imagecreate(303, 182);

$white = imagecolorallocate($image, 255, 255, 255);
$black = imagecolorallocate($image, 0, 0, 0);

imagerectangle($image, 0, 0, 302, 181, $black);

// output the image
header("Content-type: image/jpeg");
imagejpeg($image);
imagedestroy($image);
?>

Inigoesdr
10-15-2007, 02:53 AM
// first image(background)
$image = imagecreate(303, 182);
$white = imagecolorallocate($image, 255, 255, 255);
$black = imagecolorallocate($image, 0, 0, 0);
imagerectangle($image, 0, 0, 302, 181, $black);

// second image(foreground)
$imagestring = file_get_contents('http://www.google.com/intl/en_ALL/images/logo.gif');
$image2 = imagecreatefromstring($imagestring);

// merge the two images
imagecopy($image, $image2, 10, 10, 0, 0, imagesx($image2), imagesy($image2));

// output the image
header("Content-type: image/jpeg");
imagejpeg($image);
imagedestroy($image);