Need an advice

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Piratos

Re: Need an advice

Post by Piratos »

The ability to create pictures is the ability of your webserver and the GD -Lib.
PNG need the zlib library and so PNG can only use formats that works with GD and zlib.

if your webserver works with gif (i mean writing gif's with GD -> php 4.3.9 or greater) you can extend the script
as follow and you can use gif's.

  if(!in_array($infos_img[2], array(1,2,3))) return;  // png oder jpg oder gif
  if (!$infos_wz === false && !is_file($tmpfname))
  {
    if(!in_array($infos_wz[2], array(1,2,3))) return;  // png oder jpg  oder gif
    if($infos_img[0]<$infos_wz[0] || $infos_img[1]<$infos_wz[1]) return;
    $pos_x = round(($infos_img[0]-$infos_wz[0])/2, 0);
    $pos_y = round(($infos_img[1]-$infos_wz[1])/2, 0);
    if($infos_img[2] == 1)
        $img_image = imagecreatefromgif($image);
    if($infos_img[2] == 2)
        $img_image = imagecreatefromjpeg($image);
    if($infos_img[2] == 3)
        $img_image = imagecreatefrompng($image);
    if($infos_wz[2] == 1)
        $img_watermark = imagecreatefromgif($wz);
    if($infos_wz[2] == 2)
        $img_watermark = imagecreatefromjpeg($wz);
    if($infos_wz[2] == 3)
    $img_watermark = imagecreatefrompng($wz);

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

Positions:

The Position comes from the values of pos_x and pos_y - you must overwrite it, here some examples
(delete the lines you do not need)
Note: if you change this you must delete the exsting watermark pictures because they exists and no new watermark picture was created

    // watermark in the center - the normal
    $pos_x = round(($infos_img[0]-$infos_wz[0])/2, 0);
    $pos_y = round(($infos_img[1]-$infos_wz[1])/2, 0);
    //watermark in the right lower
    $pos_x = $infos_img[0]-$infos_wz[0];
    $pos_y = $infos_img[1]-$infos_wz[1];
    //watermark in the left lower
    $pos_x = 1;
    $pos_y = $infos_img[1]-$infos_wz[1];
    //watermark in the left upper
    $pos_x = 1;
    $pos_y = 1;

Window.close
The picture was send directly to the popup, i have yet not found a way to enable window.close.
Piratos

Re: Need an advice

Post by Piratos »

if you want to use gif you must change that too:

if(strtolower(substr($tmpfname, -3)) == "png")
    {
        if(!imagepng($img_image, $tmpfname)) return;
    } elseif(strtolower(substr($tmpfname, -3)) == "gif")
    {
        if(!imagegif($img_image, $tmpfname)) return;
    }
    else
    {
      if(!imagejpeg($img_image, $tmpfname)) return;
    }
URAN

Re: Need an advice

Post by URAN »

My PHP version is 4.4.2, should work, will try

You are a great guy, thank you very much :)
mattster2002

Re: Need an advice

Post by mattster2002 »

Hey guys,
I'm wanting to add a watermark to my images using this code, but just for one image, How would I go about using this with say the mod called album? I want to add GIF Watermarks in the bottom right corner of images displayed in album. I'm guessing I can use a smarty template to display the image? What are your thoughts

Thanks in advance
Locked

Return to “Modules/Add-Ons”