Forum

Questions and discussions

watermark ... not middle... bad!

Script's setup and configuration

watermark ... not middle... bad!

Postby Indivstock » Fri Feb 01, 2013 9:26 pm

how to get the watermark in middle?
watch this for example.. very bad! http://www.indivstock.com/stock-photo/portrait-of-a-pretty-young-woman-8772.html
Indivstock
 

Re: watermark ... not middle... bad!

Postby PascalP » Sat Feb 02, 2013 7:13 pm

hi,
267 x 400 px @ 72 dpi

Your image of copyright must be lower than your least wide image.
Thus lower than 267px
PascalP
 
Posts: 41
Joined: Thu Apr 22, 2010 4:42 pm
Location: Tours, France

Re: watermark ... not middle... bad!

Postby admin » Mon Feb 04, 2013 11:55 am

The watermark width must be smaller that a vertical thumb width.

The question is asked frequently. So we have modified the process a little (the script's version was not released else)
You could edit the file:
/admin/function/functions.php

and replace the code:
Code: Select all
//Watermark
function watermark($img_sourse,$png_file)
{
   global $watermark_position;

   $im1 = imagecreatefrompng($png_file);
   $im2 = ImageCreateFromJPEG($img_sourse);
   $sz = getimagesize($img_sourse);
   $wz = getimagesize($png_file);

   $px=0;
   $py=0;
   if($wz[0]<$sz[0] and $wz[1]<$sz[1])
   {
      if($watermark_position==1)
      {
         $px=0;
         $py=0;
      }
      elseif($watermark_position==2)
      {
         $px=($sz[0]-$wz[0])/2;
         $py=0;
      }
      elseif($watermark_position==3)
      {
         $px=$sz[0]-$wz[0];
         $py=0;
      }
      elseif($watermark_position==4)
      {
         $px=0;
         $py=($sz[1]-$wz[1])/2;
      }
      elseif($watermark_position==5)
      {
         $px=($sz[0]-$wz[0])/2;
         $py=($sz[1]-$wz[1])/2;
      }
      elseif($watermark_position==6)
      {
         $px=$sz[0]-$wz[0];
         $py=($sz[1]-$wz[1])/2;
      }
      elseif($watermark_position==7)
      {
         $px=0;
         $py=$sz[1]-$wz[1];
      }
      elseif($watermark_position==8)
      {
         $px=($sz[0]-$wz[0])/2;
         $py=$sz[1]-$wz[1];
      }
      else
      {
         $px=$sz[0]-$wz[0];
         $py=$sz[1]-$wz[1];
      }
   }


   imagecopy($im2,$im1, $px, $py, 0, 0,$wz[0],$wz[1]);
   
   //imageinterlace($im2, true);
   ImageJPEG($im2,$img_sourse,100);
   ImageDestroy($im1);
   ImageDestroy($im2);
}



with:
Code: Select all
//Watermark
function watermark($img_sourse,$png_file)
{
   global $watermark_position;

   $im1 = imagecreatefrompng($png_file);
   $im2 = ImageCreateFromJPEG($img_sourse);
   $sz = getimagesize($img_sourse);
   $wz = getimagesize($png_file);

   $px=0;
   $py=0;
   $wx=0;
   $wy=0;
   if($wz[0]<$sz[0] and $wz[1]<$sz[1])
   {
      if($watermark_position==1)
      {
         $px=0;
         $py=0;
      }
      elseif($watermark_position==2)
      {
         $px=($sz[0]-$wz[0])/2;
         $py=0;
      }
      elseif($watermark_position==3)
      {
         $px=$sz[0]-$wz[0];
         $py=0;
      }
      elseif($watermark_position==4)
      {
         $px=0;
         $py=($sz[1]-$wz[1])/2;
      }
      elseif($watermark_position==5)
      {
         $px=($sz[0]-$wz[0])/2;
         $py=($sz[1]-$wz[1])/2;
      }
      elseif($watermark_position==6)
      {
         $px=$sz[0]-$wz[0];
         $py=($sz[1]-$wz[1])/2;
      }
      elseif($watermark_position==7)
      {
         $px=0;
         $py=$sz[1]-$wz[1];
      }
      elseif($watermark_position==8)
      {
         $px=($sz[0]-$wz[0])/2;
         $py=$sz[1]-$wz[1];
      }
      else
      {
         $px=$sz[0]-$wz[0];
         $py=$sz[1]-$wz[1];
      }
   }
   
   if($wz[0]>=$sz[0] and $wz[1]>=$sz[1])
   {
      $px=0;
      $py=0;
      $wx=($wz[0]-$sz[0])/2;
      $wy=($wz[1]-$sz[1])/2;
   }
   
   if($wz[0]<$sz[0] and $wz[1]>=$sz[1])
   {
      $px=($sz[0]-$wz[0])/2;
      $py=0;
      $wx=0;
      $wy=($wz[1]-$sz[1])/2;
   }
   
   if($wz[0]>=$sz[0] and $wz[1]<$sz[1])
   {
      $px=0;
      $py=($sz[1]-$wz[1])/2;
      $wx=($wz[0]-$sz[0])/2;
      $wy=0;
   }

   imagecopy($im2,$im1, (int)$px, (int)$py, (int)$wx, (int)$wy,$wz[0],$wz[1]);
   
   //imageinterlace($im2, true);
   ImageJPEG($im2,$img_sourse,100);
   ImageDestroy($im1);
   ImageDestroy($im2);
}
admin
Site Admin
 
Posts: 1465
Joined: Sun Mar 07, 2010 5:55 pm

Re: watermark ... not middle... bad!

Postby Indivstock » Wed Feb 06, 2013 12:49 am

thank you
Indivstock
 


Return to Configuration

Who is online

Users browsing this forum: No registered users and 2 guests

cron
  Photo Store Script

Professional php photo stock script and WordPress plug-in for photographers and video producers.

  Support
  CMSaccount Inc.