Web Hosting Talk







View Full Version : PHP: GD image overlap


aashx
12-26-2004, 04:26 AM
Hello Frens,

I have one big image say : 800 X 600 px and a small image say 100 X 50 px (as logo).

Now what i want to do is. i want to create a single final image on fly using GD library such that a small image is placed on right bottom corner of the bigger image. Like a copyright note. (but not just text, i want my websites logo there).

So, can anyone suggest me what can i do for that?

I have GD library installed on the server.

regards,
AashX

Burhan
12-26-2004, 08:21 AM
<?php
// Transparency, 100 for none, 0 for not visible
$WaterMark_Transparency = "50";

// Import the images to use...
// We want the watermark to be a gif (transparency without the white.)
$WaterMark = imageCreateFromGIF("imagefile.gif");
$Main_Image = imageCreateFromPNG("imagefile.png");

// Get the width and height of each image.
$Main_Image_width = imageSX($Main_Image);
$Main_Image_height = imageSY($Main_Image);
$WaterMark_width = imageSX($WaterMark);
$WaterMark_height = imageSY($WaterMark);

// This will be the position of the WaterMark
$MaterMark_x = ($Main_Image_width - $WaterMark_width);
$MaterMark_y = ($Main_Image_height - $WaterMark_height);

// We want to put the watermark on top of the main image.
imageCopyMerge($Main_Image, $WaterMark, $MaterMark_x, $MaterMark_y, 0, 0, $WaterMark_width, $WaterMark_height, $WaterMark_Transparency);

// Let the browser know that it is an image..
header("Content-Type: image/PNG");

// We want to show the image (in png format...)
ImagePNG ($Main_Image);
?>


From tutoralized.com (http://www.tutorialized.com/tutorial/Add-a-WaterMark-to-the-lower-right-corner-of-a-pre-existing-image./5299)

aashx
12-27-2004, 01:56 AM
Hello fyrestrtr,

thanks for you help. it worked. :)

regards,
AashX