add logo
Moderator: General Moderators
- elecktricity
- Forum Contributor
- Posts: 128
- Joined: Sun Sep 25, 2005 8:57 pm
- Location: Trapped in my own little world.
- Contact:
add logo
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?
- elecktricity
- Forum Contributor
- Posts: 128
- Joined: Sun Sep 25, 2005 8:57 pm
- Location: Trapped in my own little world.
- Contact:
- elecktricity
- Forum Contributor
- Posts: 128
- Joined: Sun Sep 25, 2005 8:57 pm
- Location: Trapped in my own little world.
- Contact:
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 ..
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 ..
- elecktricity
- Forum Contributor
- Posts: 128
- Joined: Sun Sep 25, 2005 8:57 pm
- Location: Trapped in my own little world.
- Contact:
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...
How to use function
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. 
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";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);
}