Page 1 of 1

phpWatermark

Posted: Thu Nov 10, 2005 5:15 pm
by Tami
something to play with, released as GPL

What Is phpWatermark?
phpWatermark is a php class aiming to provide a simple way of marking an image with a digital “watermark” to prevent unauthorized use.

What’s new?

* Experimental support for adding images has been included. This function is currently absolutely unusable for production environments as it completely ignores the transparency settings of the overlay images. If you find a way to correct this error please let me know!
* Many people asked me how to change the color of the embedded text. Versions prior to 0.3 did not support this, phpWatermark always tried to determine a usable color by itself. Starting with 0.3 you may specify a color by yourself either via a hex code or rgb values.
attachment
Developer's Site

phpWatermark

Posted: Thu Nov 10, 2005 6:37 pm
by Josh
I've been messing with it... decided to go looking for tutorials on this cause I couldn't get it to work like I wanted. I can't figure out how to watermark with php.... nothing works. PNG's don't have their transparency whenever they are combined with a JPEG.

phpWatermark

Posted: Thu Nov 10, 2005 6:53 pm
by Josh
[code]<?php
// Transparency, 100 for none, 0 for not visible
$WaterMark_Transparency = "50";

// Import the images to use...
// We want the watermark to be a gif (transparency without the white.)
$WaterMark = imageCreateFromGIF("watermark.gif");
$Main_Image = imageCreateFromJPEG("image.jpg");

// Get the width and height of each image.
$Main_Image_width = imageSX($Main_Image);
$Main_Image_height = imageSY($Main_Image);
$WaterMark_width = imageSX($WaterMark);
$WaterMark_height = imageSY($WaterMark);

// This will be the position of the WaterMark
$MaterMark_x = ($Main_Image_width - $WaterMark_width);
$MaterMark_y = ($Main_Image_height - $WaterMark_height);

// We want to put the watermark on top of the main image.
imageCopyMerge($Main_Image, $WaterMark, $MaterMark_x, $MaterMark_y, 0, 0, $WaterMark_width, $WaterMark_height, $WaterMark_Transparency);

// Let the browser know that it is an image..
header("Content-Type: image/PNG");

// We want to show the image (in png format...)
ImagePNG ($Main_Image);
?>[/code]

This works. Anyone want to take a shot at creating a form to put images you want watermarked in there and save them on the server?

Oh.. Watermark has to be a GIF.....