Page 1 of 1
adding (c) image to bottom of another image
Posted: Thu Jul 10, 2003 1:17 am
by macewan
What am interested in doing is adding a small "copyright notice image" to the bottom of images that are being displayed. In the example below - the black and white image would be image 'bob.jpg' and the red image with the standard white text would be image 'fred.jpg'.
bob.jpg and fred.jpg are combined to create the image known as example.jpg
The reason I want to overlay pictures with a standard copyright image instead of just adding text to the image is that it, well, I just want to do it that way. =)
any suggestions? pointers?

Posted: Thu Jul 10, 2003 3:24 am
by qartis
You can't just draw a red box, and put the text on top of it?
Posted: Thu Jul 10, 2003 7:36 am
by cactus
You want to have a look at the image processing methods provided by the GD libs, dependant on your version of PHP you may already have these installed.
Ref : XL. Image functions
http://www.php.net/manual/en/ref.image.php
With these functions you can overlay text/color etc on a background image, which is esentially what you are trying to do.
Regards,
Posted: Thu Jul 10, 2003 7:51 am
by qartis
The reason I want to overlay pictures with a standard copyright image instead of just adding text to the image is that it, well, I just want to do it that way. =)
It sounds like he knows how to do text, he just wants do to it with an image instead. Maybe he wants to get a graphic (C) sign, with a little background image, or something? Not sure.
Posted: Thu Jul 10, 2003 10:40 am
by macewan
I want to lay 'fred.jpg' on top of every an image when needed.
http://www.deadmule.com/macewan/screens ... p/fred.jpg
Posted: Thu Jul 10, 2003 2:00 pm
by macewan
thanks to everyone for the suggestions. this is what i will be using.
http://www.php.net/manual/en/function.i ... ymerge.php
*thanks cactus for the link*
Posted: Thu Jul 10, 2003 2:25 pm
by macewan
http://www.deadmule.com/macewan/testing/
=)
click test.php
*shesh. the hosting company is moving servers so here's the code*
Code: Select all
<?php
$im = "copyright.png";
// $bg = "ffddee"; // hex representation of the color (i.e. #ffffff for white)
$out = "jpg"; // or "jpg" for jpg file output
$backgroundfile = "back.jpg"; // optional backgroundfile if you don't want to use a color
//
// function to convert hex colorcode to decimal
//
function colordecode($hex){
$codeїr] = hexdec(substr($hex, 0 ,2));
$codeїg] = hexdec(substr($hex, 2 ,2));
$codeїb] = hexdec(substr($hex, 4 ,2));
return $code;
} // end func colordecode
// create the resource id
$image_id = imageCreateFromPNG($im);
// get image size
$im_X = ImageSX($image_id);
$im_Y = ImageSY($image_id);
// create a truecolor background image of the right size
// or use a background image like this
$backgroundimage = imageCreateFromJPEG($backgroundfile);
//$backgroundimage = imagecreatetruecolor($im_X, $im_Y);
// get the desired backgroundcolor:
// don't use this if you want to use a background image
// $code = colordecode($bg);
// $backgroundcolor = ImageColorAllocate($backgroundimage, $codeїr], $codeїg], $codeїb]);
// ImageFilledRectangle($backgroundimage, 0, 0, $im_X, $im_Y, $backgroundcolor);
// merge the two together with alphablending on!
ImageAlphaBlending($backgroundimage, true);
imagecopy($backgroundimage, $image_id, 0, 0, 0, 0, $im_X, $im_Y);
// output the image:
if($output == "jpg"){
Header( "Content-type: image/jpeg");
ImageJPEG($backgroundimage);
}
else{
Header( "Content-type: image/png");
ImagePNG($backgroundimage);
}
// destroy the memory
ImageDestroy($backgroundimage);
ImageDestroy($image_id);
?>