Author Topic: Auto Watermark?  (Read 12614 times)

0 Members and 1 Guest are viewing this topic.

Offline johnnypowpow

  • Pre-Newbie
  • Posts: 2
    • View Profile
Auto Watermark?
« on: December 29, 2002, 08:53:57 PM »
Hi, I've seen in a few other scripts using both the GD library and Imagemagick that you can have the script do an auto-watermark on the full-size images upon upload.

I have the php script for a gallery called photopost that does this if anyone could look it over and see if this could be applied to 4images.

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
Auto Watermark?
« Reply #1 on: December 29, 2002, 10:43:49 PM »
I'm interesting in it too. where I can get that script?
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 Reimer

  • Newbie
  • *
  • Posts: 15
    • View Profile
Auto Watermark?
« Reply #2 on: December 29, 2002, 11:06:50 PM »
I use a Photoshop action to insert my url automaticly. You just have to load the watermark and than start the action.

Reimer
http://4desktops.de

Offline johnnypowpow

  • Pre-Newbie
  • Posts: 2
    • View Profile
Auto Watermark?
« Reply #3 on: December 30, 2002, 01:38:22 AM »
Quote from: Reimer
I use a Photoshop action to insert my url automaticly. You just have to load the watermark and than start the action.
Quote


the problem with that is then the thumbnail generated will have that watermark on it as well....would be tough to see the thumbnail image very well.

the script i'm talking about is a seperate php gallery app called photopost.
if anyone could look at photopost and then make a mod to 4images to make that work......email me at:

seowitz at seowitz dot com

Offline larra200

  • Pre-Newbie
  • Posts: 1
    • View Profile
Re: Auto Watermark?
« Reply #4 on: June 23, 2007, 01:59:11 PM »
I'm interesting in it too. where I can get that script?

Whel if u still whant a script like that here u go.

-----------------------------------------------------
-------------- Index.php ------------------
-----------------------------------------------------

Code: [Select]
<?php

require_once 'WaterMark.php';

$wm = new WaterMark;
$wm->setMarkSource('watermark.png');
$wm->setPosition(WaterMark::TOP_RIGHT);
$wm->setXOffset(-0);
$wm->setYOffset(-0);
$wm->mark('un_marked.jpg');
$wm->saveAsJpeg('marked.jpg');

Note no "?>"

-----------------------------------------------------
------------- WaterMark.php -------------
-----------------------------------------------------

Quote
<?php

class WaterMark
{

   const TOP_LEFT       = 0x1;
   const TOP_RIGHT      = 0x2;
   const BOTTOM_LEFT   = 0x4;
   const BOTTOM_RIGHT   = 0x8;
   
   protected $wmtarget   = null;
   protected $wmresource   = null;
   protected $wmx_offset   = 0;
   protected $wmy_offset   = 0;
   protected $wmposition   = 0x8;
   protected $wmwidth   = 0;
   protected $wmheight   = 0;

   public function setMarkSource($wmfile)
   {
      if(!is_readable($wmfile))
         return false;
         
      list($w, $h, $wmmime) = $this->getImageInfo($wmfile);
      
      switch($wmmime)
      {
         case 'image/jpeg':
            $this->resource = imagecreatefromjpeg($wmfile);
            break;
         case 'image/png':
            $this->resource = imagecreatefrompng($wmfile);
            break;
         case 'image/gif':
            $this->resource   = imagecreatefromgif($wmfile);
            break;
         default:
            $this->resource = null;
            $this->width   = 0;
            $this->height   = 0;
            return false;
         break;
      }
      
      $this->width    = $w;
      $this->height   = $h;
      
      return true;
   }
   
   public function setPosition($wmposition)    { $this->position    = (int)$wmposition;   }
   public function setXOffset($wmoffset)    { $this->x_offset    = (int)$offset;    }
   public function setYOffset($wmoffset)      { $this->y_offset    = (int)$wmoffset;    }
   
   public function setTransparencyColor($r, $g, $b)
   {
      if($r > 255) $r = 255;
      if($b > 255) $g = 255;
      if($g > 255) $b = 255;
      
      if(is_null($this->resource))
         return false;
         
      $identifier = imagecolorallocate($this->resource, $r, $g, $b);
      
      if($identifier === false)
         return false;
      
      imagecolortransparent($this->resource, $wmidentifier);
   }
   
   public function markGDResource($wmtarget)
   {
      $this->target    = $wmtarget;   
      $wmtarget_x      = imagesx($wmtarget);
      $wmtarget_y       = imagesy($wmtarget);
   
      switch($this->position)
      {
         case self::TOP_LEFT:
            $wmtarget_x = 0;
            $wmtarget_y = 0;
         break;
         case self::TOP_RIGHT:
            $wmtarget_x -= $this->width;
            $wmtarget_y = 0;
         break;
         case self::BOTTOM_LEFT:
            $wmtarget_x = 0;
            $wmtarget_y -= $this->height;
         break;
         case self::BOTTOM_RIGHT:
         default:
            $wmtarget_x -= $this->width;
            $wmtarget_y -= $this->height;
         break;
         
      }
      
      return imagecopy($wmtarget, $this->resource, $wmtarget_x+$this->x_offset, $wmtarget_y+$this->y_offset, 0, 0, $this->width, $this->height);
   }
   
   public function mark($wmfile, $return = false)
   {
   
      if(is_null($this->resource))
         return false;
         
      list($wmtarget_x, $wmtarget_y, $wmmime) = $this->getImageInfo($wmfile);
   
      switch($wmmime)
      {
         case 'image/jpeg':
            $wmtarget = imagecreatefromjpeg($wmfile);
         break;
         case 'image/png':
            $wmtarget = imagecreatefrompng($wmfile);
         break;
         default:
            return false;
         break;
      }
      
      $this->markGDResource($wmtarget);
      
      if($return === true)
         return $wmtarget;
   }
   
   public function saveAsJpeg($wmname = null, $wmquality = 100)
   {
      if(is_null($this->target))
         return false;
      
      return imagejpeg($this->target, $wmname, $wmquality);
   }
   
   public function saveAsPng($wmname = null)
   {
      if(is_null($this->target))
         return false;
         
      return imagepng($this->target, $wmname);
   }
   
   protected function getImageInfo($wmfile)
   {
      $info = getimagesize($wmfile);
      return array($info[0], $info[1], $info['mime']);
   }


}

Or download the zip file i added ;)

Offline EdwinK

  • Pre-Newbie
  • Posts: 8
    • View Profile
Re: Auto Watermark?
« Reply #5 on: September 02, 2008, 11:09:36 PM »
Thought it works, but.. it didn't.

Is it only working when uploading pictures after installation of this mod/plugin? Or should I be able to let it run on all images I've got?

Tried uploading an image, but it didn't get the watermark.

I downloaded the version from here, and didn't type it myself.

Offline mawenzi

  • Moderator
  • 4images Guru
  • *****
  • Posts: 4.500
    • View Profile
Re: Auto Watermark?
« Reply #6 on: September 03, 2008, 12:05:15 AM »
... can have the script do an auto-watermark on the full-size images upon upload.

... it is possibile ... ;)
... there are some 4images MODs, they all together can do this ...

1. [TUT] One Image - Three sizes : http://www.4homepages.de/forum/index.php?topic=20496.0
... this MODs will save your full size image in a extra folder upon a upload ...
... and resize the image for your detail page ...
... and generate a download link to your full size image via download button ...

2. [MOD] Image Annotations (Watermark) : http://www.4homepages.de/forum/index.php?topic=13719.0
... this MOD generate a watermak to your images upon a upload ...
... there you must change the settings to generate the watermark only on the full size images ...

I think that's all for your request... ;)
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 EdwinK

  • Pre-Newbie
  • Posts: 8
    • View Profile
Re: Auto Watermark?
« Reply #7 on: September 08, 2008, 11:28:16 PM »
Tried this, but after been trying for some time, I still don't get it to work. I did so many changes to the files, I now don't longer know what file is doing what. Going to try to restore all files to as they were when I first downloaded them.

Offline mawenzi

  • Moderator
  • 4images Guru
  • *****
  • Posts: 4.500
    • View Profile
Re: Auto Watermark?
« Reply #8 on: September 08, 2008, 11:56:07 PM »
@ EdwinK

... it's right and I know, it's a hard piece of work and coding ...
... but the instructions are all already there ... and finaly it works in the way as I have described ...
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 EdwinK

  • Pre-Newbie
  • Posts: 8
    • View Profile
Re: Auto Watermark?
« Reply #9 on: September 18, 2008, 07:56:56 PM »
This is what I got now:

Code: [Select]
Warning: include_once(./../global.php) [function.include-once]: failed to open stream: No such file or directory in /home/bookieb/public_html/gallery/admin/admin_global.php on line 29

Warning: include_once() [function.include]: Failed opening './../global.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/bookieb/public_html/gallery/admin/admin_global.php on line 29

Warning: include_once(./../includes/sessions.php) [function.include-once]: failed to open stream: No such file or directory in /home/bookieb/public_html/gallery/admin/admin_global.php on line 30

Warning: include_once() [function.include]: Failed opening './../includes/sessions.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/bookieb/public_html/gallery/admin/admin_global.php on line 30

Warning: include_once(./../admin/admin_functions.php) [function.include-once]: failed to open stream: No such file or directory in /home/bookieb/public_html/gallery/admin/admin_global.php on line 31

Warning: include_once() [function.include]: Failed opening './../admin/admin_functions.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/bookieb/public_html/gallery/admin/admin_global.php on line 31

Warning: opendir(./../lang/) [function.opendir]: failed to open dir: No such file or directory in /home/bookieb/public_html/gallery/admin/admin_global.php on line 59

Warning: closedir(): supplied argument is not a valid Directory resource in /home/bookieb/public_html/gallery/admin/admin_global.php on line 67

Fatal error: Call to undefined function show_admin_header() in /home/bookieb/public_html/gallery/admin/admin_global.php on line 70

Offline mawenzi

  • Moderator
  • 4images Guru
  • *****
  • Posts: 4.500
    • View Profile
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) ...