Advertisement:

Watermark script help

Aloittaja Dzonny, toukokuu 29, 2009, 03:41:34 IP

« edellinen - seuraava »

Dzonny

Hi to all.. :)

I've found some script that will add watermark to every pic on my page, so i want to add it on my forum, and i need help with that...
script can be found here:
http://www.baglan.web.tr/watermarking-php

This is code:
# .htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule \.(gif|jpeg|jpg|png)$ watermark.php [QSA,NC]

<?php
// watermark.php

// Path the the requested file
$path $_SERVER['DOCUMENT_ROOT'].$_SERVER['REQUEST_URI'];

// Load the requested image
$image imagecreatefromstring(file_get_contents($path));

$w imagesx($image);
$h imagesy($image);

// Load the watermark image
$watermark imagecreatefrompng('watermark.png');
$ww imagesx($watermark);
$wh imagesy($watermark);

// Merge watermark upon the original image
imagecopy($image$watermark$w-$ww$h-$wh00$ww$wh);

// Send the image
header('Content-type: image/jpeg');
imagejpeg($image);
exit();
?>



So, i dont quite understand where to put that? Maybe index,template.php or...?

Dzonny

Hm, ok, i would take that for attachment then, it could be ok...

Tristan Perry

In the folder where you want the images watermarked, make a file called ".htaccess" with:

# .htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule \.(gif|jpeg|jpg|png)$ watermark.php [QSA,NC]


In it. In the same folder, make a file named "watermark.php" with:

<?php
// watermark.php

// Path the the requested file
$path $_SERVER['DOCUMENT_ROOT'].$_SERVER['REQUEST_URI'];

// Load the requested image
$image imagecreatefromstring(file_get_contents($path));

$w imagesx($image);
$h imagesy($image);

// Load the watermark image
$watermark imagecreatefrompng('watermark.png');
$ww imagesx($watermark);
$wh imagesy($watermark);

// Merge watermark upon the original image
imagecopy($image$watermark$w-$ww$h-$wh00$ww$wh);

// Send the image
header('Content-type: image/jpeg');
imagejpeg($image);
exit();
?>


I think that's it at least :)

Tristan Perry

Yes you are right Arantor, good point :)

It's a pretty useful script in certain situations, however it needs modifying to work with SMF. Or at least, it can't really be used with default SMF settings.

However, for example, this script would work fine in this board - since avatars here are of the form http://www.simplemachines.org/community/custom_avatars/avatar_[number].png

Dzonny

Thanks for your answers guys...

This is an example of watermark script, only in Attachment...
http://forum.burek.com/if-you-leave-me-t442344.html

i saw that Russians are made watermark script on their smf forum, and i'm asking them to help and waiting answer... ;/
In a meanwhile, i way trying to add this code, but i'm not shore where to add the code....in attachment directory?

Dzonny

No, i want it to work only in uploaded attachments...
As it is on link that i post in previous post...
That is evidentially possible, couse i seen it on some other forums....

Dzonny

I'm using 1.1.9 now...

Im just searching, and found some sites that can be userful, so if you want, you can look at it:
http://www.trap17.com/index.php/Watermark-Image-Simple-Php-Script_t36015.html
http://bokehman.com/watermark


Thank you very much for helping with this...

bostonb

I am very interested in this approach too, adding the watermark in during the upload process of the attachment, have you had any luck with this?

using 1.1.9

franklinrony

http://twitter.com/franklinrony

Entra y aprende a ser un webmaster
www.sv-blog.com
--Si pides ayuda al menos agradece el soporte recibido----


franklinrony

http://twitter.com/franklinrony

Entra y aprende a ser un webmaster
www.sv-blog.com
--Si pides ayuda al menos agradece el soporte recibido----

bostonb

Lainaus käyttäjältä: frony - kesäkuu 22, 2009, 07:46:19 IP
maybe this mod help you

I tried to install the 1.1 version of that and it errored on the xml language files part

"Modification parse error"

Dzonny

I was install it on my test forum, but it didint work... And it's on russian, so i cant understand what to do...
Somehow i've enable it in admin panel, but still have no watermarked images....

bostonb

Lainaus käyttäjältä: Dzonny - kesäkuu 23, 2009, 09:45:31 AP
I was install it on my test forum, but it didint work... And it's on russian, so i cant understand what to do...
Somehow i've enable it in admin panel, but still have no watermarked images....

same here, I had to uninstall for now.... I hope someone can get this working or adapt it somehow

I wonder if all of the unencoded text in the english.xml file is part of the problem? the script itself doesn't look that long

franklinrony

yes, i test in spanish, my language, and work fine, you must translate to work
http://twitter.com/franklinrony

Entra y aprende a ser un webmaster
www.sv-blog.com
--Si pides ayuda al menos agradece el soporte recibido----

bostonb

Lainaus käyttäjältä: frony - kesäkuu 23, 2009, 08:22:04 IP
yes, i test in spanish, my language, and work fine, you must translate to work

thanks frony, that is good to know that it works

I guess that leaves going into the english.xml file and line by line picking out the encoded text and converting it to an english equivalent so it doesn't trip up the install

would be easier if I spoke Russian :P  maybe someone that does speak it here could run through the edit really quick for us?

franklinrony

spanish to english could be more easier
http://twitter.com/franklinrony

Entra y aprende a ser un webmaster
www.sv-blog.com
--Si pides ayuda al menos agradece el soporte recibido----

Dzonny

#17
oh....Someone can translate this to English? :/

Edit: Working now, but i cant see characters in  Additional Options...

bostonb

Lainaus käyttäjältä: Dzonny - kesäkuu 24, 2009, 05:17:54 AP
oh....Someone can translate this to English? :/

Edit: Working now, but i cant see characters in  Additional Options...

did you have to manually install? did you use the russian language?

havok99

hi again - now that i downloaded the smf zip file - what do i do next?

Advertisement: