Home Tutorial Php Phpgd PHP GD watermark an Image

 
 

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

<?php

ini_set("display_errors", "1");

error_reporting(E_ALL);

$image_src = 'images.jpg';

$watermark_src = 'watermark.jpg';

$opacity = 30;

$padding = 20;

$image = imagecreatefromjpeg($image_src);

$watermark = imagecreatefromjpeg($watermark_src);

list($image_width, $image_height) = getimagesize($image_src);

list($watermark_width, $watermark_height) = getimagesize($watermark_src);

$final_x = $image_width - $watermark_width - $padding;

$final_y = $image_height - $watermark_height - $padding;

imagecopymerge($image, $watermark, $final_x, $final_y, 0, 0, $watermark_width, $watermark_height, $opacity);

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

imagejpeg($image, null, 100);

imagedestroy($image);

imagedestroy($watermark);

?>

Advertisement

Related Tags for PHP GD watermark an Image:


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 11, 2009

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com