• [MOD] Transparent Watemark on all upload images 5 0 5 1
Currently:  

Author Topic: [MOD] Transparent Watemark on all upload images  (Read 24261 times)

0 Members and 1 Guest are viewing this topic.

Offline MrAndrew

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
    • Aviation PhotoBase
[MOD] Transparent Watemark on all upload images
« on: May 26, 2010, 11:50:31 AM »
I was developed it for my site and i want to give this mod to all...

Description:

This mod will autamatically apply watermark on all your images. It may be show at your desicion. This MOD will not affect on image quality!

Installation Level:    Easy
Installation Time:      5 Minutes

New files:
_watermark
watermark.png
.htaccess

1. Create a _watermark.php and put this code in this file:
Code: [Select]
<?

waterMark($_SERVER['DOCUMENT_ROOT'].$_SERVER['REQUEST_URI'], "watermark.png", "top=20,center=");

function waterMark($original, $watermark, $placement = 'middle=5, center=50', $destination = null) {
   $original = urldecode($original);
   $info_o = @getImageSize($original);
   if (!$info_o)
         return false;
   $info_w = @getImageSize($watermark);
   if (!$info_w)
         return false;

   list ($vertical, $horizontal) = split(',', $placement,2);
   list($vertical, $sy) = split('=', trim($vertical),2);
   list($horizontal, $sx) = split('=', trim($horizontal),2);

   switch (trim($vertical)) {
      case 'bottom':
         $y = $info_o[1] - $info_w[1] - (int)$sy;
         break;
      case 'middle':
         $y = ceil($info_o[1]/2) - ceil($info_w[1]/2) + (int)$sy;
         break;
      default:
         $y = (int)$sy;
         break;
      }

   switch (trim($horizontal)) {
      case 'right':
         $x = $info_o[0] - $info_w[0] - (int)$sx;
         break;
      case 'center':
         $x = ceil($info_o[0]/2) - ceil($info_w[0]/2) + (int)$sx;
         break;
      default:
         $x = (int)$sx;
         break;
      }

   header("Content-Type: ".$info_o['mime']);

   $original = @imageCreateFromString(file_get_contents($original));
   $watermark = @imageCreateFromString(file_get_contents($watermark));
   $out = imageCreateTrueColor($info_o[0],$info_o[1]);

   imageCopy($out, $original, 0, 0, 0, 0, $info_o[0], $info_o[1]);
   if( ($info_o[0] > 250) && ($info_o[1] > 250) )
   {
   imageCopy($out, $watermark, $x, $y, 0, 0, $info_w[0], $info_w[1]);
   }

   switch ($info_o[2]) {
      case 1:
         imageGIF($out);
         break;
      case 2:
         imageJPEG($out, NULL, 100);
         break;
      case 3:
         imagePNG($out);
         break;
         }

   imageDestroy($out);
   imageDestroy($original);
   imageDestroy($watermark);

   return true;
   }

?>

2. Create a picture, which you want to show as watermark with name watermark.png


3. Create directory with name watermark and put this 2 files into (_watermark.php and watermark.png) and upload this to the root directory

4. Create a .htaccess file with this code and put this file to data/:
In case if you have a validation on you site put this file to data/tmp_media,
In case if you have a straight upload on you site put this file to data/media/(category which you want watermarked),
Upload this file to all directories (data/media/[all directories] and tmp_media) if you want watermark all you images from database
Code: [Select]
DirectoryIndex index.php
 
<FilesMatch "\.(gif|jpg|png|JPG)$">
   RewriteEngine On
   RewriteCond %{REQUEST_FILENAME} -f
   RewriteRule ^(.*)$ /watermark/_watermark.php [T=application/x-httpd-php,L,QSA]
</FilesMatch>

DEMO:
« Last Edit: August 15, 2010, 08:23:48 PM by V@no »

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.805
  • I ♥ 4I
    • View Profile
Re: [MOD] Transparent Watemark on all upload images
« Reply #1 on: May 26, 2010, 03:20:15 PM »
Added to:
http://www.4homepages.de/forum/index.php?topic=24888.msg136127#msg136127

THX

But all Pictures and Icons have a watermark, not only the Details-Images
« Last Edit: May 26, 2010, 04:49:05 PM by Sumale.nin »

Offline MrAndrew

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
    • Aviation PhotoBase
Re: [MOD] Transparent Watemark on all upload images
« Reply #2 on: May 26, 2010, 11:21:58 PM »
Hmmm, starnge!

Ae you sure that you upload .htaccess only in tmb_media or media???

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Transparent Watemark on all upload images
« Reply #3 on: May 27, 2010, 02:48:10 AM »
Thanks for the mod, I'd bet Sumale.nin added code into .htaccess in root, not in data folder :)
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.805
  • I ♥ 4I
    • View Profile
Re: [MOD] Transparent Watemark on all upload images
« Reply #4 on: May 27, 2010, 11:29:15 AM »
Yes :D

Sorry! But now is perfect!!

Offline Enforcer

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: [MOD] Transparent Watemark on all upload images
« Reply #5 on: July 09, 2010, 03:47:04 AM »
if i'm using this,
i just can see the alt tag,
no image, no watermark

any suggestions?

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Transparent Watemark on all upload images
« Reply #6 on: July 09, 2010, 02:21:51 PM »
Hello and welcome to 4images forum.
If you can, see if anything in server's error logs

Also, just in case replace <? at the beginning of _watermark.php with:
<?php
error_reporting
(E_ALL);
ini_set("display_errors"1);

then try open an image directly, see if anything shows.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Enforcer

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: [MOD] Transparent Watemark on all upload images
« Reply #7 on: July 10, 2010, 04:14:11 PM »
Not Found
The requested document was not found on this server.

Web Server at *.de


but the image exists at the ftp server...
a configuration problem?

when i delete the htacces file i can see the image normaly

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Transparent Watemark on all upload images
« Reply #8 on: July 10, 2010, 06:52:52 PM »
Make sure the path to the _watermark.php is correct in this line:
Code: [Select]
  RewriteRule ^(.*)$ /watermark/_watermark.php [T=application/x-httpd-php,L,QSA]
For example if your web root located at this local path:
/home/username/htdocs/
and your 4images at this:
/home/username/htdocs/gallery/

then the path to the _watermark.php should be like this:
/home/username/htdocs/gallery/watermark/_watermark.php
or like this:
/gallery/watermark/_watermark.php
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline asiancook

  • Pre-Newbie
  • Posts: 2
    • View Profile
Re: [MOD] Transparent Watemark on all upload images
« Reply #9 on: August 15, 2010, 01:45:07 PM »
nice mod, but how to change the location of the watermark to the bottom right?

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Transparent Watemark on all upload images
« Reply #10 on: August 15, 2010, 04:38:35 PM »
Welcome to 4images forum.

Replace waterMark($_SERVER['DOCUMENT_ROOT'].$_SERVER['REQUEST_URI'], "watermark.png""top=20,center="); 


with:waterMark($_SERVER['DOCUMENT_ROOT'].$_SERVER['REQUEST_URI'], "watermark.png""bottom=20,center="); 
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline asiancook

  • Pre-Newbie
  • Posts: 2
    • View Profile
Re: [MOD] Transparent Watemark on all upload images
« Reply #11 on: August 15, 2010, 04:51:28 PM »
thank you, now i know were too look. Adapted it to go to the bottom right.

Offline mawenzi

  • Moderator
  • 4images Guru
  • *****
  • Posts: 4.500
    • View Profile
Re: [MOD] Transparent Watemark on all upload images
« Reply #12 on: August 15, 2010, 05:33:43 PM »
2. Create a picture, which you want to show as watermark with name watermark.php

... this is incorrect and should mean correct ...

2. Create a picture, which you want to show as watermark with name watermark.png
Your first three "must do" before you ask a question ! ( © by V@no )
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

You are on search for top 4images MOD's ?
- then please search here ... Mawenzi's Top 100+ MOD List (unsorted sorted) ...

Offline tomerl

  • Newbie
  • *
  • Posts: 40
    • View Profile
Re: [MOD] Transparent Watemark on all upload images
« Reply #13 on: November 11, 2010, 05:35:03 PM »
Hallo,

Wenn ich den Mod installiere, werden in meiner Galerie nur mehr die roten Kreuze statt Bilder angezeigt.
Was mache ich da falsch?
Versteh auch nicht ganz welches image ich da erzeugen soll.

Offline x23piracy

  • Sr. Member
  • ****
  • Posts: 420
    • View Profile
    • FHG
Re: [MOD] Transparent Watemark on all upload images
« Reply #14 on: November 11, 2010, 06:42:00 PM »
Hi,

n1 and easy idea for watermarking without changing 4I code  :thumbup: but...

howto handle different image sizes?
It seems the script doesn't fit the watermark to image size...

Looks strange if your watermark was made for example
1024x768 but is displayed with a 100x100 image.

Can someone improve this?


Greetz X23

Don't trust in md5 it's unsafe change your 4i galerys password hash algorythm! second pw db field, create new hashes over some time, deny old hash. Help members that cry, send informationen mail to the rest. Camouflage new pw hash in cookie. Done!

--(◔̯◔)--