Hi, Does anyone know of any free Automatic image watermarking that I can implement into a image uploading script.
Thanks.
Hi, Does anyone know of any free Automatic image watermarking that I can implement into a image uploading script.
Thanks.
Use CSS:
If you want to give it a "watermark" effect, use an image-editing program.Code:background:url('myimage.jpg') no-repeat fixed top left;
- Mike
Thanks for quick reply but is it possible for PHP to get an image, put a watermark over it so its only one image. I think it is because PHP can create captcha codes on the fly.
You should be able to combine two images fairly easily.
Create a loop that runs through all of the pixels, then for each that is white in the watermark image, make the pixel of the main image a blend of the watermark pixel and image pixel. If black, leave as is. Or any variation you want.
Basically, something like--
PHP Code:<?php
$imgurl = $_GET['img'];
$image=imageCreateFromJPEG($imgurl);
//or create your image from upload
$imagewidth = imagesx($image);
$imageheight = imagesy($image);
//get dimensions
$watermarkurl = $_GET['wm'];
$watermark=imageCreateFromGIF($watermarkurl);
//as above, do what you want for getting the watermark
$wmwidth = imagesx($watermark);
$wmheight = imagesy($watermark);
//get dimensions of watermark
imagecopyresampled($watermark, $watermark, 0, 0, 0, 0, $imagewidth, $imageheight, $wmwidth, $wmheight);
//resize the watermark to be in the same dimensions as the image
for ($y = 0; $y < $imageheight; $y++) {
for ($x = 0; $x < $imagewidth; $x++) {
$imgcolor = imagecolorat($image,$x,$y);
$imgcolorrgb = imagecolorsforindex($image,$imgcolor);
$ir = $imgcolorrgb['red'];
$ig = $imgcolorrgb['green'];
$ib = $imgcolorrgb['blue'];
$wmcolor = imagecolorat($watermark,$x,$y);
$wmcolorrgb = imagecolorsforindex($watermark,$wmcolor);
$wr = $wmcolorrgb['red'];
$wg = $wmcolorrgb['green'];
$wb = $wmcolorrgb['blue'];
if ($ir<$wr&&$ig<$wg&&$ib<$wb) {
$pxcolor = imagecolorallocate($image, ($ir+$wr)/2, ($ig+$wg)/2, ($ib+$wb)/2);
imagesetpixel($image, $x, $y, $pxcolor);
}
}
}
//loop through image
//and set pixel to white
//if wm is white at pixel
header("Content-type: image/jpg");
imagejpeg($image);
imagedestroy($image);
//output
?>
Last edited by djr33; 03-19-2007 at 11:52 PM.
Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
Does gd library support layers?
if so, a semitransperent png ontop of the watermarked picture would be the best option.
Its support for layers is annoying and not very trustworthy.
Anyway, I've been testing, and here's the result:
http://ci-pro.com/misc/phptest/image...er/Image25.gif
From two random sources:
http://www.huddletogether.com/projec...es/image-1.jpg
http://www.informika.ru/text/magaz/higher/Image25.gif
Note: The code in the last post is updated to reflect changes I made.
Last edited by djr33; 03-19-2007 at 11:52 PM.
Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
It's a bit laggy though.
Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
Currently: enjoying the early holidays :)Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide
Sure. It's running through every pixel.
This is for watermarking on upload, so it shouldn't be an issue.
Write a faster script if you question this
...PHP is slow with images, but I have yet to find a way around that.
Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
Bookmarks