Jump to content

Watermarking Image


graham23s

Recommended Posts

Hi Guys,

 

When i upload and merge my watermark .png on to my  images it still shows the square border rather than just the logo, the square borders should be invisible.

 

My watermark code:

	 // DEFINITIONS...
     define('WATERMARK_OVERLAY_IMAGE', '../img/img-wmLogo.png');
     define('WATERMARK_OVERLAY_OPACITY', 100);
     define('WATERMARK_OUTPUT_QUALITY', 100);

Function code:

function create_watermark($source_file_path, $output_file_path)
{
 list($source_width, $source_height, $source_type) = getimagesize($source_file_path);
 if ($source_type === NULL) {
 return false;
 }
 
 switch ($source_type) 
 {
 case IMAGETYPE_GIF:
 $source_gd_image = imagecreatefromgif($source_file_path);
 break;
 case IMAGETYPE_JPEG:
 $source_gd_image = imagecreatefromjpeg($source_file_path);
 break;
 case IMAGETYPE_PNG:
 $source_gd_image = imagecreatefrompng($source_file_path);
 break;
 default:
 return false;
 }
 
 $overlay_gd_image = imagecreatefrompng(WATERMARK_OVERLAY_IMAGE);
 $overlay_width = imagesx($overlay_gd_image);
 $overlay_height = imagesy($overlay_gd_image);
 imagecopymerge($source_gd_image,$overlay_gd_image,$source_width - $overlay_width,$source_height - $overlay_height,0,0,$overlay_width,$overlay_height,WATERMARK_OVERLAY_OPACITY);
 imagejpeg($source_gd_image, $output_file_path, WATERMARK_OUTPUT_QUALITY);
 imagedestroy($source_gd_image);
 imagedestroy($overlay_gd_image);
 
}

It appears like: http://www.camnev-electronics.com/wwwwwwwwwwwwwwwwwwwwwwwww-2743.html and http://www.camnev-electronics.com/test-2739.html

 

I know nothing about photoshop but my designer has swore blue the background is transparant, is this a coding problem would you say? i can't think of what else to chjeck.

 

any help would be appreciated!

 

cheers guys

 

Graham

Link to comment
Share on other sites

Can you provide a sample of the wartermark image?

 

FYI: Based upon the two links provided, it seems you used two different images for the watermark and you received two different results (one is partially transparent and the other is not transparent at all). Since the same code was changed, my initial reaction is that the difference is caused by the different images.

Edited by Psycho
Link to comment
Share on other sites

Hi P,

 

Ah that is because i messed with the opacity settings here:

define('WATERMARK_OVERLAY_OPACITY', 100);

I used 100 for the black one, and 50 for the transparent one :)

 

Here is the latest one: http://www.camnev-electronics.com/img/img-wmLogo.png and another: http://www.camnev-electronics.com/img/wmlogo1.png

 

I cannot figure it out at all lol

 

cheers P

 

Graham

Edited by graham23s
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.