Home Tutorial Php Phpgd PHP GD watermark on Images

 
 

Share on Google+Share on Google+
PHP GD watermark on Images
Posted on: November 17, 2009 at 12:00 AM
Advertisement
This example shows how Add to watermark image in php gd.

<?php

$main_img = "main.jpg";

$watermark_img = "RI-Logo.jpg";

$padding = 50;

$opacity = 30;

$watermark = imagecreatefromjpeg($watermark_img);

$image = imagecreatefromjpeg($main_img);

if(!$image || !$watermark) die("Error: main image or watermark could not be loaded!");

$watermark_size = getimagesize($watermark_img);

$watermark_width = $watermark_size[0];

$watermark_height = $watermark_size[1];

$image_size = getimagesize($main_img);

$dest_x = $image_size[0] - $watermark_width - $padding;

$dest_y = $image_size[1] - $watermark_height - $padding;

imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, $opacity);

header("content-type: image/jpeg");

imagejpeg($image);

imagedestroy($image);

imagedestroy($watermark);

?>

After running the program you will get the following output

Advertisement

Related Tags for PHP GD watermark on Images:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: November 17, 2009

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com