Based on On The Fly Images 1.0 - Watermark and Thumbnail Generation. ----------------------------------------------------------- by Rob O'Donnell. Jan 2004. ==================================================== On The Fly Watermark Enhanced 1.1 ----------------------------------------------------------- by ORIENT | September 9, 2004 This enhanced version of Rob's cool contrib is intended to better the display of watermarks with the following three handsome features added. 1. Watermarks are displayed at the center of the original images. 2. Watermarks are shown at their original transparency. 3. Two watermarks of different sizes for smaller and larger orignal images respectively. This is my first contrib to osC. After taking quite a number of contrib from here, I think it¡¯s my time to contribute back. However, I¡¯m not a php expert myself, so I fully adopted Rob¡¯s great idea on utilizing the .htaccess means to realize the watermarking effect and amended his code to this. It took me almost a whole day to finally achieve my goal. I¡¯ve tested it thoroughly on my own site, and it works cool. When installing Rob¡¯s contrib, I found the watermark image was displayed in an ugly way, due to the following three inadequate shortages. 1. Watermark is displayed at the upper left corner, thus might not cover the major part of the original image. 2. Watermark is not transparent, making it not very professional for the viewers. 3. Different size of original images display a universal watermark, therefore, watermark appears very huge on small images but tiny on big ones. You¡¯ll find only one .php file in the archive, which eliminates all these three shortages above. Basically there¡¯s no need for you to modify the image.php file, unless you changed the size of the watermark samples mentioned below. The water.htaccess is pretty the same as Rob¡¯s. Please change [full path to your image.php directory] to the actual path your site. And after upload it to your image directory, please remember to change its file name to .htaccess (nothing before the dot). I also included two sample watermark images, namely watermark.png (300X90, saying ¡°THIS IS THE BIG LOGO) and watermark_s.png (150X50, saying ¡°THIS IS THE SMALL LOGO¡±). You may open them with MacroMedia Fireworks to edit. For images wider than 300 pixels, the watermark.png will be displayed, while smaller images displaying watermark_s.png. If you¡¯d like to make your own watermarks in a different resolution, and would like to change the 300 pixels rule, you may open image.php file with a text editor and locate ¡°//The figure "300" can be changed to any figure suitable for your situation.¡± line, and make change according to your need. Please upload them to the same directory of image.php. And that¡¯s it. You may see the watermark result now. To recap the installation process: 1. Upload image.php watermark.png watermark_s.php to the same directory on your sever, say /home/public_html/watermark/ 2. Open water.htaccess with your favorite text editor, and change [full path to your image.php directory] to the directory accordingly 3. Upload water.htaccess to the directory (directories) where all the images you wanna watermark locate, and rename water.htaccess to .htaccess Tips for your customization: 1. Both .png files must be in PNG32 format with transparent background and percentage transparent objects. 2. If you want to change the rule of displaying which watermark and/or the position of the watermarks, please open image.php file and make changes to the following part of code if (ImageSX($main_img) > 300) { $posx = (ImageSX($main_img) - ImageSX($watermark_img))/2; $posy = (ImageSY($main_img) - ImageSY($watermark_img))/2; imagecopy($main_img, $watermark_img, $posx, $posy, 0, 0, $wmrk_size[0], $wmrk_size[1]); }else{ $posxs = (ImageSX($main_img) - ImageSX($watermarks_img))/2; $posys = (ImageSY($main_img) - ImageSY($watermarks_img))/2; imagecopy($main_img, $watermarks_img, $posxs, $posys, 0, 0, $wmrks_size[0], $wmrks_size[1]); } Though I didn¡¯t test the contrib on thumb part of Rob¡¯s On The Fly Image 1.0, I think it¡¯ll work fine with it if it already works well. If my effort on this contrib making your admin life easier and happier and you¡¯d like to donate, please pm me in the forum. Thanks in advance! Further discussions of this contrib can be located at: