![]() |
|
Image Watermarking/ Copyright with GD - Printable Version +- ZenphotoCMS Forum (https://forum.zenphoto.org) +-- Forum: Support (https://forum.zenphoto.org/forum-1.html) +--- Forum: General support (https://forum.zenphoto.org/forum-4.html) +--- Thread: Image Watermarking/ Copyright with GD (/thread-505.html) |
Image Watermarking/ Copyright with GD - Skwid - 2006-06-17 Hey everyone, I did my 'watermarking' my own way ! Using text rather than images. This way, the text can be easily changed by editing the setting in zp-config.php, and there is no need to create an image. You can see it here (just get to an image) The code calculates the text color based on the average color of the area that is underneath ! Image Watermarking/ Copyright with GD - trisweb - 2006-06-18 Looks pretty cool Skwid, think you could make it transparent and anti-aliased? If you want, bundle it up and submit a patch at http://bugs.zenphoto.org. Image Watermarking/ Copyright with GD - thinkdreams - 2006-06-18 In case anyone wanted to see it in action, I have a zenphoto implementation up at http://www.photosbydaisy.com/zenphoto which is utilizing Skwid's watermarking function. Thinkdreams Image Watermarking/ Copyright with GD - Skwid - 2006-06-18 Hum trisweb, I'm not sure if i can make transparent text using GD functions, plus it would be hard to read it ... By the way, I wrote you an email, but never had an answer. If you didn't have time that's fine, but if you didn't get it, please tell me so I can resend it. Image Watermarking/ Copyright with GD - thinkdreams - 2006-06-18 This might do the trick: http://www.phpbuilder.com/snippet/download.php?type=snippet&id=68 I haven't had a chance to try it yet though. It solves the different font thing we were talking about the other night Skwid. Image Watermarking/ Copyright with GD - Skwid - 2006-06-19 Ok, I got the watermarking working with a transparent PNG made from custom text, font, color, whatever You can see it in action at the usual URL: This is color transparency, i still need to work on alpha transparency. Image Watermarking/ Copyright with GD - nathan - 2006-06-20 Oh... Crap. I forgot to upload the article. Gimmie a sec and I will do it now. I use images, but the script handles alpha transparency, anti-aliasing and png-24 formatted images (the big plus for quality). Image Watermarking/ Copyright with GD - nathan - 2006-06-20 Okay. First of all, sorry for being late. I completely forgot about it. Here is what needs to be done. For ease of configuration, there are some changes to the zp-config.php file AS WELL as the i.php file. I will try and step it out with easy instructions, but if I am unclear on anything, please let me know. This will eventually be the wiki page.
` // turn the watermarking on and off $conf['perform_watermark'] = true; // the image (png-24) in the zen/images/ directory $conf['watermark_image'] = "images/watermark.png"; ` You can add those anywhere ABOVE the line that says: / Do not edit below this line. / /**/ `
` $perform_watermark = zp_conf('perform_watermark'); $watermark_image = zp_conf('watermark_image'); `
`
` That is it. Make sure you put the image in the This WILL also add the watermark to the thumbs. To turn that off, add this line in the thumbnailing part og the
Is that wiki worthy? Image Watermarking/ Copyright with GD - thinkdreams - 2006-06-20 works good for me nathan. the image is a 50% opacity .png created with a text font in photoshop. http://www.thinkdreams.com/devzp/scenery/IMG_3280.JPG Image Watermarking/ Copyright with GD - nathan - 2006-06-20 Great. I'll tidy up the text/ grammar and add it to the wiki. Image Watermarking/ Copyright with GD - DarrellD - 2006-06-21 Very nice solution to watermarking. The only problem that I have with this hack is that it will only work for those themes which use values set in zp-config.php because those themes use the [b]getImageThumb()[/b] and [b]printImageThumb()[/b] functions. For both of my themes, I never used those because I wanted to basically "hard-code" (i.e. [b]getCustomImageURL()[/b]) the sizes of the thumbnails. In order to get it to work with that function, I'll have to do some major work with [b]i.php[/b] and even [b]classes.php[/b]. Also, I'd like to make a suggestion to your code. `//////////////////////////////////////////////////////////////////////////////// // Watermark Hack ////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////` This code also takes care of the fact that it's a thumbnail. Image Watermarking/ Copyright with GD - DarrellD - 2006-06-21 Okay, after further thought, here goes a fix that will work for my themes (and maybe others that use the [b]getCustomImageURL()[/b]). The only thing is that you'll have to edit more than just [b]i.php[/b]. copy and paste the following code into [b]i.php[/b] around line 213 (just as stated in the above post): `//////////////////////////////////////////////////////////////////////////////// // Watermark Hack ////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////` now from lines 257-263 of [b]classes.php[/b] change the function from: `function getCustomImage($size, $width, $height, $cropw, $croph, $cropx, $cropy) {
}` to the following: `function getCustomImage($size, $width, $height, $cropw, $croph, $cropx, $cropy, $wm=true) {
}` Then in [b]template-functions.php[/b] change lines 554-558 from: `function getCustomAlbumThumb($size, $width=NULL, $height=NULL, $cropw=NULL, $croph=NULL, $cropx=NULL, $cropy=null) { global $_zp_current_album; $thumb = $_zp_current_album->getAlbumThumbImage(); return $thumb->getCustomImage($size, $width, $height, $cropw, $croph, $cropx, $cropy); }` to the following: `function getCustomAlbumThumb($size, $width=NULL, $height=NULL, $cropw=NULL, $croph=NULL, $cropx=NULL, $cropy=null, $wm=false) { global $_zp_current_album; $thumb = $_zp_current_album->getAlbumThumbImage(); return $thumb->getCustomImage($size, $width, $height, $cropw, $croph, $cropx, $cropy, $wm); }` Also in [b]template-functions.php[/b] change lines 892-903 from: `function getCustomImageURL($size, $width=NULL, $height=NULL, $cropw=NULL, $croph=NULL, $cropx=NULL, $cropy=NULL) { global $_zp_current_image; return $_zp_current_image->getCustomImage($size, $width, $height, $cropw, $croph, $cropx, $cropy); }` `function printCustomSizedImage($alt, $size, $width=NULL, $height=NULL, $cropw=NULL, $croph=NULL, $cropx=NULL, $cropy=NULL, $class=NULL, $id=NULL) { $sizearr = getSizeCustomImage($size, $width, $height, $cropw, $croph, $cropx, $cropy); echo "[img][/img]"; }` to the following: `function getCustomImageURL($size, $width=NULL, $height=NULL, $cropw=NULL, $croph=NULL, $cropx=NULL, $cropy=NULL, $wm=true) { global $_zp_current_image; return $_zp_current_image->getCustomImage($size, $width, $height, $cropw, $croph, $cropx, $cropy, $wm); }` `function printCustomSizedImage($alt, $size, $width=NULL, $height=NULL, $cropw=NULL, $croph=NULL, $cropx=NULL, $cropy=NULL, $class=NULL, $id=NULL, $wm=true) { $sizearr = getSizeCustomImage($size, $width, $height, $cropw, $croph, $cropx, $cropy); echo "[img][/img]"; }` What this code does is that by default, when you use [b]getCustomImageURL()[/b] it will automatically watermark your image (this way your images are ALWAYS protected. If you want to turn it off (to maybe make a custom-sized thumbnail), just set the [b]8th[/b] parameter of the function to [b]false[/b]. However, it's the opposite for [b]getCustomAlbumThumb()[/b]. Because we have it explicitly get a thumb, we have $wm be false by default. That should do it. Image Watermarking/ Copyright with GD - nathan - 2006-06-21 This is a fairly lengthy hack. I'll take a look at seeing if there is a different way to do this. I tired my best to make the code small, and this is really a bit too much for what I was after. I like this bit though: // Watermark Hack //////////////////////////////////////////////////////////////////////////////// $perform_watermark = zp_conf('perform_watermark'); $watermark_image = zp_conf('watermark_image'); if ($perform_watermark == true && $thumb == false && $_GET['wm'] == true) { $watermark = imagecreatefrompng($watermark_image); imagealphablending($watermark, false); imagesavealpha($watermark, true); $watermark_width = imagesx($watermark); $watermark_height = imagesy($watermark); // Position Overlay in Bottom Right $dest_x = imagesx($newim) - $watermark_width; $dest_y = imagesy($newim) - $watermark_height; imagecopy($newim, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height); imagedestroy($watermark); } ////////////////////////////////////////////////////////////////////` Thanks for that. Image Watermarking/ Copyright with GD - nathan - 2006-06-21 Sorry for a double post, but we might be able to get this included in the zenphoto project. That way, people won't have to edit ALL the files themselves. They won't have to do anything really. I'll open a feature request in the bug tracker. Image Watermarking/ Copyright with GD - DarrellD - 2006-06-21 Well, if this will be worked in "officially" it would be great if not only would we be able to specify the default watermark image in the config, but if we were also able to specify a different watermark image during runtime. This would be useful, for example, if I wanted a default watermark on my bigger images (say it was a logo and my domain name), but then later on decide to watermark my thumbnails with just the logo. When I call the function to specify a thumbnail, I could just easily give it the name of the new watermark. Image Watermarking/ Copyright with GD - Daxeno - 2006-06-26 This is still not in the Wiki. Image Watermarking/ Copyright with GD - trisweb - 2006-06-27 Good point Daxeno. ;-) Image Watermarking/ Copyright with GD - Daxeno - 2006-06-27 and it seems not working as well. Image Watermarking/ Copyright with GD - thinkdreams - 2006-06-27 Dax- I was able to get the antialiasing working on my site OK. What seems to not be working? Thinkdreams. Image Watermarking/ Copyright with GD - thinkdreams - 2006-06-27 In case you haven't seen it, http://www.thinkdreams.com/devzp is where my test site is at. I used Nathan's original code, without the GameDudeX modifications (just haven't had time to integrate them yet). Thinkdreams |