GregZ Posted September 12, 2007 Share Posted September 12, 2007 I have 3_Sizes_of_product_images_Update_for_22ms2_v1.10 installed and I wanted to watermark some of my product images. I have 3 sizes of images, 125 x125, 250 x250 and 500 x 500. I only wanted water marks on the 2 larger sizes. A friend suggested re-naming the 2 larger sizes from .jpg to .jpeg and altering the script to act as a filter. This sounded like too much work since the pics were already uploaded. Before the modification all of pics in the image fill got watermarked- even the manufacturer pics. I made one simple change to the script in the image.php file . Now the small watermark only appears on pics larger than 200 pixels and the large is only on pics larger than 300 pixels. Here's the modified text, the line in BOLD is the only thing added : <?php //watermark program //Show that a jpeg image is going to be returned //echo $QUERY_STRING; //exit; header("Content-type: image/jpeg"); //File names $wmark='watermark.png'; $wmarks='watermark_s.png'; $noimg='noimg.png'; $mimage=$QUERY_STRING; // mod to display default image instead of 404 if (file_exists($QUERY_STRING)) { //echo "The file $QUERY_STRING exists"; //Loading $watermark_img = imagecreatefrompng($wmark); $watermarks_img = imagecreatefrompng($wmarks); $wmrk_size = getimagesize($wmark); $wmrks_size = getimagesize($wmarks); $main_img = imagecreatefromjpeg($mimage); //ImageAlphaBlending($main_image, true); //Merge the 2 buffers //The figure "300" can be changed to any figure suitable for your situation. 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 if (ImageSX($main_img) > 200) { $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]); } //Output file to browser imagejpeg($main_img); imagedestroy($watermark_img); imagedestroy($watermarks_img); imagedestroy($main_img); } else { //echo "The file $QUERY_STRING does not exist"; //Loading $noimg_show = imagecreatefrompng($noimg); //Output file to browser imagejpeg($noimg_show); imagedestroy($noimg_show); } ?> You can see it in action at my test site here: Visit My TEST Website I'm planning on going live within the next few weeks. Quote Link to comment Share on other sites More sharing options...
lifeisboost Posted September 21, 2007 Share Posted September 21, 2007 is there anyway to make this contrib only water mark certain images? I.E. im using more pics 6, what i ned to do is say, only water mark images 1,2,5,6 but not the others. can anyone help with this? Quote Link to comment Share on other sites More sharing options...
Paradisebg Posted November 17, 2007 Share Posted November 17, 2007 May I use Watermark in popup_image.php? And how? My popup_image.php code is: <?php require('includes/application_top.php'); $navigation->remove_current_page(); $products_query = tep_db_query("select pd.products_name, p.products_image from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['pID'] . "' and pd.language_id = '" . (int)$languages_id . "'"); $products = tep_db_fetch_array($products_query); // BOF: More Pics 6 $PID = $HTTP_GET_VARS['pID']; $invis = $HTTP_GET_VARS['invis']; $result = mysql_query("select * from " . TABLE_PRODUCTS . " where products_id = '" . (int)$HTTP_GET_VARS['pID'] . "'"); // EOF: More Pics 6 ?> <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> <html <?php echo HTML_PARAMS; ?>> <head> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> <title><?php echo $products['products_name']; ?></title> <base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>"> <script language="javascript" type="text/javascript"><!-- var i=0; function resize() { if (window.navigator.userAgent.indexOf('MSIE 6.0') != -1 && window.navigator.userAgent.indexOf('SV1') != -1) { i=25; //+IE 6.x on Windows XP SP2 } else if (window.navigator.userAgent.indexOf('MSIE 6.0') != -1) { i=25; //+IE 6.x somewhere else } else if (window.navigator.userAgent.indexOf('MSIE 7.0') != -1) { i=0; //+IE 7.x } else if (window.navigator.userAgent.indexOf('Firefox') != -1 && window.navigator.userAgent.indexOf("Windows") != -1) { i=30; //+Firefox on Windows } else if (window.navigator.userAgent.indexOf('Mozilla') != -1 && window.navigator.userAgent.indexOf("Windows") != -1 && window.navigator.userAgent.indexOf("MSIE") == -1) { i=45; //Mozilla on Windows, but not IE7 } else if (window.opera && document.childNodes) { i=40; //+Opera 7+ } else if (navigator.vendor == 'KDE' && window.navigator.userAgent.indexOf("Konqueror") != -1) { i=-4; //Konqueror- this works ok with small images but not so great with large ones //if you tweak it make sure i remains negative } else { i=70; //All other browsers } if (document.images[0]) { imgHeight = document.images[0].height+150-i; imgWidth = document.images[0].width+30; var height = screen.height; var width = screen.width; var leftpos = width / 2 - imgWidth / 2; var toppos = height / 2 - imgHeight / 2; window.moveTo(leftpos, toppos); window.resizeTo(imgWidth, imgHeight); } self.focus(); } //--></script> <?php // BOF: More Pics 6 ?> <meta http-equiv="Page-Enter" content="blendTrans(Duration=0.5)"> <?php // EOF: More Pics 6 ?> </head> <body onLoad="resize();"> <?php // BOF: More Pics 6 ?> <table border="0" cellpadding="0" cellspacing="0" align="center"> <?php // Lets find the last available image ! $image = tep_db_fetch_array($result); if ($image['products_subimage6'] != ''){ $last = '6'; }elseif ($image['products_subimage5'] != ''){ $last = '5'; }elseif ($image['products_subimage4'] != ''){ $last = '4'; }elseif ($image['products_subimage3'] != ''){ $last = '3'; }elseif ($image['products_subimage2'] != ''){ $last = '2'; }elseif ($image['products_subimage1'] != ''){ $last = '1'; }elseif ($image['products_image'] != ''){ $last = '0'; } $next = $invis + '1'; $back = $invis - '1'; ?> <?php if (($invis == '0') || ($invis == '')){ $insert = $image['products_image']; } else { $insert = $image['products_subimage' . $invis. '']; } $img = DIR_WS_IMAGES . $insert; echo '<tr><td align="center">' .tep_image(DIR_WS_IMAGES . $insert) . '</td>'; ?> <tr><td height="20" align="center"> <?php if (($back != '-1') || ($next <= $last)) { echo '<hr color="#666666" size="3">'; } if ($back != '-1'){ echo '<a href="'.tep_href_link('popup_image.php','pID='.$PID.'&invis='.$back).'">' . tep_image(DIR_WS_IMAGES.'left.gif', 'previous', '', '', 'border="0"') . '</a> '; } if ($next <= $last){ echo '<a href="'.tep_href_link('popup_image.php','pID='.$PID.'&invis='. $next).'">' . tep_image(DIR_WS_IMAGES.'right.gif', 'next', '', '', 'border="0"') . '</a>'; } echo '</td></tr>'; ?> </tr> </table> <?php // EOF: More Pics 6 ?> </body> </html> <?php require('includes/application_bottom.php'); ?> <?php require(DIR_WS_INCLUDES . 'disable.php'); ?> Thank you Quote Link to comment Share on other sites More sharing options...
go_go_go Posted November 22, 2007 Share Posted November 22, 2007 i used env.php to find out the root directory. And write this root path into .htacess like the following.. RewriteEngine on RewriteRule ^(.*)\.jpg /home/public_html/products/image.php?%{REQUEST_FILENAME} I put this .htaccess into the /images folder (here is all the .jpg image i want to put the watermark on), then i put image.php, watermark.png, watermark_s.png and noimg png into /products folder. However, I still couldn't make this watermark contribution work.. I am sure i got my root path correct. But still no luck to work out this contribution. Is there anything i was missing? Anyone can help? Thank you! Quote Link to comment Share on other sites More sharing options...
digicammad Posted December 17, 2007 Share Posted December 17, 2007 Hi. I seem to have a different problem to everybody else in that this contribution is working too well. :rolleyes: I would like to see the photo thumbnails with no watermark, but even if I comment out the small watermark code in the image.php file everything is watermarked. I assume this is because the thumbnails are created just using width and height commands and the real image size is still > 300px. Is there a way around this? Thanks Ian Quote Link to comment Share on other sites More sharing options...
Floob Posted March 17, 2008 Share Posted March 17, 2008 Is there anyway to rewrite the "RewriteRule ^(.*)\.jpg" part in the .htaccess file so that only jpg files with a "-" character in the filename get watermarked?Thanks, Eric That would be handy. Anyone know how to do this? Quote Link to comment Share on other sites More sharing options...
Floob Posted March 17, 2008 Share Posted March 17, 2008 That would be handy. Anyone know how to do this? -.*\.jpg$ Quote Link to comment Share on other sites More sharing options...
jmvaras Posted May 5, 2008 Share Posted May 5, 2008 Hi everybody. I've installed this wonderful contribution and I have a problem. I do everything, but I can't see the watermark. However, I execute with Internet Explorer http://www.myshop.com/images/image.php? with the name of one jpg file in the folder and the image appears OK with its watermark. So I think that the problem must be in the .htaccess file. I have put it in the images folder with all the paths I have, and it doesn't work. I've used this: RewriteRule ^(.*)\.jpg docroot/tienda/catalog/images/image.php?%{REQUEST_FILENAME} RewriteRule ^(.*)\.jpg /docroot/tienda/catalog/images/image.php?%{REQUEST_FILENAME} RewriteRule ^(.*)\.jpg /tienda/catalog/images/image.php?%{REQUEST_FILENAME} RewriteRule ^(.*)\.jpg tienda/catalog/images/image.php?%{REQUEST_FILENAME} My http path is http://www.myshop.com/tienda/catalog, but the physic path is with docroot. (www.myshop.com is not the real domain) What can I do? Thanks a lot. Quote Link to comment Share on other sites More sharing options...
smic717394 Posted May 27, 2008 Share Posted May 27, 2008 Hi this is a great contribution. My shop uses 3 sizes photos 100 x 100, 250 x 250 and 500 x 500, i only wanted the watermark on the medium and large photos and only on hotlink, so i changed a bit see files bellow. Everything works very nice but when the photos is displayed from another domain the watermark is displayed that is nice but the photo lose quality, even the small 100 x 100, can i fix that or someone has any sugestions? Feel free to use the code if you only want to show the watermark if someone is trying to hotlink but from your domain the photo will show without the watermak. Also the watermark is on the bottom of the photo. I created in my root a folder called catalog that contains: image.php, noimg.png and watermark.png and i created the .htaccess in the photos folder. My .htaccess is: RewriteEngine on RewriteCond %{HTTP_REFERER} !^http://(.+\.)?cexy\.co.uk/ [NC] RewriteCond %{HTTP_REFERER} !^https://(.+\.)?cexy.authsecure\.com/ [NC] RewriteCond %{HTTP_REFERER} !^$ RewriteRule ^(.*)\.(jpg|jpeg|JPG) /catalog/image.php?%{REQUEST_FILENAME} My image.php is: <?php //watermark program //Show that a jpeg image is going to be returned //echo $QUERY_STRING; //exit; header("Content-type: image/jpeg"); //File names $wmark='watermark.png'; $mimage=$QUERY_STRING; // mod to display default image instead of 404 if (file_exists($QUERY_STRING)) { //echo "The file $QUERY_STRING exists"; //Loading $watermark_img = imagecreatefrompng($wmark); $wmrk_size = getimagesize($wmark); $main_img = imagecreatefromjpeg($mimage); //ImageAlphaBlending($main_image, true); //Merge the 2 buffers //The figure "300" can be changed to any figure suitable for your situation. if (ImageSX($main_img) > 150) { $posx = (ImageSX($main_img) - ImageSX($watermark_img))/2; $posy = (ImageSY($main_img) - ImageSY($watermark_img)); imagecopy($main_img, $watermark_img, $posx, $posy, 0, 0, $wmrk_size[0], $wmrk_size[1]); } //Output file to browser imagejpeg($main_img); imagedestroy($watermark_img); imagedestroy($main_img); } ?> Quote Link to comment Share on other sites More sharing options...
pedro.antunes Posted October 25, 2008 Share Posted October 25, 2008 It doesn't work for me, I don't get any image... Even if I put in the browser an address like: http://localhost/loja/image.php?images/pro...00000023211.jpg I get the text: http://localhost/loja/image.php?images/pro...00000023211.jpg instead of the image. What am I doing wrong? Quote Link to comment Share on other sites More sharing options...
Rubin Remus Posted September 30, 2010 Share Posted September 30, 2010 Sorry to awaken an old thread, but I'm trying to implement this contrib into a store, but it merely prevents all images from opening at all. The store is quite heavily modded, and I'm wondering if the water.htaccess file is conflicting with the main .htaccess in the directory. I know I've installed it correctly (and I do have the .htaccess files in the appropriate places and named correctly - I just refer to it as water.htaccess to be more concise), but it stops literally ALL images from displaying. At the moment, I am using the image directory for all the stores images, though I will be putting them into different folders soon. Can anyone shed any light onto the cause of this issue and perhaps provide a solution or a nudge in the right direction? Thanks for any help you can give. Quote Link to comment Share on other sites More sharing options...
decart2000ro Posted May 11, 2011 Share Posted May 11, 2011 Well, as is the usually when I have a question, I post it up, and a few minutes later I answer it myself. I changed the following two lines to make this PHP5 compliant: $mimage=$QUERY_STRING; TO $mimage=$_SERVER['QUERY_STRING']; if (file_exists($QUERY_STRING)) { TO if (file_exists($mimage)) { You would also have to do the same to some of the line that are commented out if you wished to view those comments for debugging or what not. Hope this helps someone! Thanks. For All who use PHP 5 THIS is the solution,i work many days for resolving and no results and after i try this is working!!!!!!!!!! :) 10x Quote Link to comment Share on other sites More sharing options...
gate7 Posted June 26, 2012 Share Posted June 26, 2012 hello, have someone experience with integration this watermark to creloaded ? there is a link with an example of how this works? thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.