Watermarks addon changes

Please see the post below for a better how to install and update to the files!

watermark.zip

[quote name=‘mattls’]I have a simple way of watermarking all your detailed store images without ever having to do anything. Its done through .htaccess request. EG user clicks on a link to display and is shown the thumb with no image. They click to get a bigger image and its water marked.



Just do the following:

-Upload the .htacess file to your /images/detailed (or for that matter any dir that you want water marked.)

-Create a dir name wartermark

-add files : w.php & also your watermark image (which i called mark.png can be changed by editing the php file)



Thats it!



Dont know if this helps any one or not but sure makes it easier for me to just create the products & not have to do anything else.[/QUOTE]





I tried this but I am getting X mark for my detail images



What is EG user ?



is server need to setup something ?

[quote name=‘netra4u’]I tried this but I am getting X mark for my detail images



What is EG user ?



is server need to setup something ?[/QUOTE]



If your store is listed in a sub-dir you will need to edit the .htaccess file where it is :

RewriteRule .(gif|jpeg|jpg|png)$ /watermark/w.php [QSA,NC]



make sure and set it to : RewriteRule .(gif|jpeg|jpg|png)$ /YOUR STORE NAME/watermark/w.php [QSA,NC]



other wise you need to make sure your server is set to handle image creation, make sure you have GD Lib and ImageMagick installed.



This should handle any errors your getting. Please let me know otherwise and Ill take a look into it.

[quote name=‘mattls’]If your store is listed in a sub-dir you will need to edit the .htaccess file where it is :

RewriteRule .(gif|jpeg|jpg|png)$ /watermark/w.php [QSA,NC]



make sure and set it to : RewriteRule .(gif|jpeg|jpg|png)$ /YOUR STORE NAME/watermark/w.php [QSA,NC]



other wise you need to make sure your server is set to handle image creation, make sure you have GD Lib and ImageMagick installed.



This should handle any errors your getting. Please let me know otherwise and Ill take a look into it.[/QUOTE]



It works now. Thank You



How can I make watermark position to center ?

[quote name=‘netra4u’]It works now. Thank You



How can I make watermark position to center ?[/QUOTE]



Simple, in the php file edit like this:

--------------------

FIND THIS:

--------------------

$startwidth = (($imagewidth - $watermarkwidth) );

$startheight = (($imageheight - $watermarkheight) );



--------------------

REPLACE WITH:

--------------------

$startwidth = (($imagewidth - $watermarkwidth) /2);

$startheight = (($imageheight - $watermarkheight) /2);



replacing with that will center the watermark. You can mess with that number and it should change where the watermark is located. Fairly simple.

Since this thread was started by CS for their new addon, suggest you start another thread for a different implementation. Otherwise people are going to get confused as to what’s what.



One is a Mod and one is an Addon. Two very different things.

[quote name=‘tbirnseth’]Since this thread was started by CS for their new addon, suggest you start another thread for a different implementation. Otherwise people are going to get confused as to what’s what.



One is a Mod and one is an Addon. Two very different things.[/QUOTE]



Agreed, my thoughts exactly! :confused:

[quote name=‘mattls’]If your store is listed in a sub-dir you will need to edit the .htaccess file where it is :

RewriteRule .(gif|jpeg|jpg|png)$ /watermark/w.php [QSA,NC]



make sure and set it to : RewriteRule .(gif|jpeg|jpg|png)$ /YOUR STORE NAME/watermark/w.php [QSA,NC]



other wise you need to make sure your server is set to handle image creation, make sure you have GD Lib and ImageMagick installed.



This should handle any errors your getting. Please let me know otherwise and Ill take a look into it.[/QUOTE]



Hi,



I already try this method, but still not working.



I using rewrite to host multiple domains


RewriteEngine On
RewriteCond %{HTTP_HOST} shop.com
RewriteCond %{REQUEST_URI} !shop/
RewriteRule ^(.*)$ shop/$1 [L]




Even I set /watermark/w.php or /shop/watermark/w.php still doesn’t work.



How can I solve it?



Thanks!

EDIT: Got it working

I have to say, this mod has worked beautifully for me. I didn't completely understand the instructions at first, but one I put the watermarking folder (that has w.php and the actual watermarked image) in the root of my cscart site, and the .htaccess file in the images/detailed folder (as I only want to watermark the largest popup images) all is working as it should.

Alright sorry for the delay to getting back to everyone. Well I haven't watched the forum because everyone was saying that I posted this little mod in the wrong place so I figured why should I help these people when all they are doing is bashing me… Anyways I want to help anyone that has a question about this…



Let me go over a few things… First this isn't dependent on cs-cart in any way and does not matter what version of cs-cart you are running. Even if its version 100.1 20 years from now. As long as the dir structure stays the same it will work fine.



Next, this in NO WAY SHAPE OR FORM will not make your images “pop up” like they used to. Once again like I said this doesnt edit any file on cs-carts side. If you dont delete the .htaccess file in the images/detailed/ dir then this will happen as the .htaccess file is trying to send the image to get watermarked.



This also will not change anything with your lightbox as stated above you forgot to delete the .htaccess file in the images dir.



Now I will reword and try to help you better understand how to install this mod.



I have revised the zip file for a little more direction on how to edit the files and made a dir structure to help on upload.



In the .htaccess file which is located in the dir /images/detailed/ it will look like this:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} -f

RewriteRule .(gif|jpeg|jpg|png)$ /watermark/w.php [QSA,NC]



If you have your store and all it's dir in a sub dir example: /store you will need to edit the .htaccess file as so:

RewriteRule .(gif|jpeg|jpg|png)$ /watermark/w.php [QSA,NC] <----- the bold needs to be edited to where you uploaded the watermark dir so if its /store then edit its to RewriteRule .(gif|jpeg|jpg|png)$ /store/watermark/w.php [QSA,NC]



Next is the watermark script its self, no editing should be needed unless you would like to change the location on the watermark or the name of your png watermark file. You will notice that your watermark image will need to be a png file!

The default name of this file is watermark.png and its located in the same folder as the w.php file!



That is it, it's very simple to use and install! Any questions feel free to message me before bashing me or the program for your user editing that is causing the problems! I dont mean to be harsh with what I say just when people are ungrateful for something given to them for free then start bashing them, it's uncalled for…



Lastly, if you need this mod and cant seem to figure out how to install it… I can install it on your system for you given FTP access to your site. Unfortunately my labor is not free but for a small fee I can get this installed and working!



Please remember that this program requires GD Lib and ImageMagick installed

watermark.zip

Well I'd like to say thanks Matt. After some initial head-scratching I figured out the mod and its working beautifully. Really saved us, as we have a lot of custom, high-res product photo's that we've taken ourselves. We didn't want the competition stealing them!



Cheers,



Scott.

Hello Mattls,



I want to start by apologizing for my rude behavior. You are offering a FREE addon after all and I had no right to act that way, especially when you are trying to help people out.



So please forgive me for acting childish as I did, I was frustrated and acted out of ignorance. :rolleyes:



Second. I finally got it working!



I think the issue was that I put the watermark dir in the detailed images dir, and not in the root dir.



The second issue was that on the first post you said you named your water mark image “mark.png”



So I did the same, not realizing that it should be “watermark.png”.



Anyhow, it works great now!





Do you have a donate button anywhere? :)





Regards,

Bill

Its no problem I really just wanted everyone to enjoy a great script that would save us all from stole images. Im glade you all go it working and I know my first set and maybe even the second set of instructions (destructions) were not clear. Im not that good at explaining how to use / install scripts or mods. I did kinda just throw it all together without showing a dir structure. That is why I updated the files and the zip file to have the correct dir structure as I was almost cretin that was the problem. Im glad everyone is happy and if you all got any questions feel free to ask.

I think if you have a store with huge traffic, this script will slow down the storefront rendering. I think the best way, that you store these images with watermark.

Hello all.

I have added some instructions to cache generated images.

Images with watermark will be stored in /wm/images/detailed/0/ directory.

So it will be only one generation of watermark.

After that every request will be forwarded to existing file.




// this script creates a watermarked image from an image file - can be a .jpg .gif or .png file
// where mark.png is a mostly transparent gif image with the watermark - goes in the same directory as this script
// where this script is named w.php


function sendfile($imagewm){
$fp = fopen($imagewm, 'rb');

// send the right headers
header("Content-Type: image");
header("Content-Length: " . filesize($imagewm));

// dump the picture and stop the script
fpassthru($fp);
fclose($fp);
return;
}

$imagesource = $_SERVER['DOCUMENT_ROOT'].$_SERVER['REQUEST_URI'];
$imagewm = $_SERVER['DOCUMENT_ROOT'].'/wm'.$_SERVER['REQUEST_URI'];

if ( file_exists($imagewm) ){
sendfile($imagewm);
return;
}else{

$filetype = substr($imagesource,strlen($imagesource)-4,4);
$filetype = strtolower($filetype);
if($filetype == ".gif") $image = @imagecreatefromgif($imagesource);
if($filetype == ".jpg") $image = @imagecreatefromjpeg($imagesource);
if($filetype == ".png") $image = @imagecreatefrompng($imagesource);
if (!$image) die();
$watermark = @imagecreatefrompng('lp.png');
$imagewidth = imagesx($image);
$imageheight = imagesy($image);
$watermarkwidth = imagesx($watermark);
$watermarkheight = imagesy($watermark);
$startwidth = 0;//(($imagewidth - $watermarkwidth) );
$startheight = (($imageheight - $watermarkheight) );
imagecopy($image, $watermark, $startwidth, $startheight, 0, 0, $watermarkwidth, $watermarkheight);
imagejpeg($image,$imagewm,90);
sendfile($imagewm);
imagedestroy($image);
imagedestroy($watermark);
}

?>

it's all ok except of the images in the option combinations.

when i tick “watermark this image” and click save,nothing happens.it says yous changes have been saved but its unticked again.

does anyone have the same problem?

edit:

got it working!works perfect!

[color=#282828][font=arial, verdana, tahoma, sans-serif]it working!works perfect![/font][/color]

How to move it to the left.