Page 1 of 1

add logo

Posted: Thu Oct 06, 2005 8:04 pm
by elecktricity
I was wondering if it was possible to have an image in like 'images/01/01.jpg' and put it on a page but with a graphic logo on it, I know it's possible to add text to it, but is it possible to add a graphic? if so can I get a link?

Posted: Thu Oct 06, 2005 8:06 pm
by feyd
I'm having real trouble trying to figure out what you are talking about. :?

Posted: Thu Oct 06, 2005 8:12 pm
by Nathaniel
Do you want PHP to dynamically add an image onto the top of another image?

Posted: Thu Oct 06, 2005 8:21 pm
by elecktricity
Nathaniel wrote:Do you want PHP to dynamically add an image onto the top of another image?
yea that, sorry if I didnt make sence, I have a hard time explaining things.

Posted: Thu Oct 06, 2005 8:50 pm
by Burrito
I still dont' understand??? you mean you want it layered on top, or you want to "morph" two images together?

if the former, look into absolute positioning of page elements...if the latter, ask onion2k about GD :D

Posted: Thu Oct 06, 2005 8:52 pm
by elecktricity
not really sure what you mean by 'morph' but I want it for 2 images to be like layered on there into 1 image

Posted: Thu Oct 06, 2005 9:17 pm
by mickd
morph as in merging the 2 images together.

Posted: Thu Oct 06, 2005 9:34 pm
by josh

Posted: Thu Oct 06, 2005 11:38 pm
by Trenchant
Put it this way. You basically want to stack the pancakes?

Corny but it works.

Posted: Fri Oct 07, 2005 3:25 am
by onion2k
http://www.ooer.com/index.php?section=php&id=9

My "Starting out with GD" article .. instead of creating a new image as I did in the article you'll need to open an existing one, and then open your logo image .. so you'll have two image handles open .. then use the imagecopy() function to copy the logo onto the first image. Copying an image onto another image is covered on page 2 of the article.

Gets more complicated if you need to preserve transparency.. if you need that then ask and I'll follow up here ..

Posted: Fri Oct 07, 2005 8:49 am
by elecktricity
thanks guys, links are muchly appreciated.

Posted: Sun Oct 09, 2005 5:42 pm
by Dm7
Here's my function example with transparent support...
Mind me, I'm making a function without testing it out, but it SHOULD work!
Be sure to set $overlay path properly.. here's the example...

Code: Select all

$overlay = "/var/www/vhosts/domain.com/httpdocs/gallery/Copyright.png";
How to use function

Code: Select all

overlayim("/var/www/vhosts/domain.com/httpdocs/gallery/Copyright.png");

Code: Select all

function overlayim($overlay) {
// Checks if overlay image exists

	if (!$overlay = imagecreatefrompng($overlay)) {
		$error = "error opening overlay image";
		$show = "error";
	}
//open original (uploaded) image, based on type.
		switch($_FILES['file']['type']) {
			case 'image/jpeg':
			case 'image/pjpeg':
				$orig = imagecreatefromjpeg($_FILES['file']['tmp_name']);
				break;
			case 'image/png':
				$orig = imagecreatefrompng($_FILES['file']['tmp_name']);
				break;
			case 'image/gif':
				$orig = imagecreatefromgif($_FILES['file']['tmp_name']);
				break;
			default:
				$error = "Unknown File Format or MIME Type";
				$show = "error"; } 
			
                if ($orig) {
	
			
			// fetch the size of the original and overlay images,
				
		$width = imagesx($orig);
		$height = imagesy($orig);
		$overlay_x = imagesx($overlay);
		$overlay_y = imagesy($overlay);
		
				// Calculate offsets for overlay (top right)
			
			$offset_x = $width - $overlay_x;
			$offset_y = 1;				
			
				// Set the transparent color in the overlay, and copy
				// it into the new image.
			imagecolortransparent($overlay);
			imagecopymerge($orig, $overlay, $offset_x, $offset_y, 0, 0, $overlay_x, $overlay_y, 75);
}
From what I have seen, it should work, but if it doesn't.. let me know please. However, you should get an idea how it works. Be sure to have a png file with alpha channel for imagecolortransparent to work. :)