Page 1 of 2

Need an advice

Posted: Thu Mar 16, 2006 2:15 pm
by URAN
Please, tell me if is some module/addon/plugin/script already known to solve it:

1. I need to open my large images at popup HTML window, not just tartget=_blank .

2. I need to apply watermark at this large images.


What module/addon/plugin/script should I use?

Re: Need an advice

Posted: Fri Mar 17, 2006 11:58 am
by jelle
Sorry, I have not seen any of that in cmsms yet.
For the popup i suggest you write a custom plugin, i'm pretty sure there is some suitable javascript out there.

For the watermarks: you should do that after uploading, as it can be relatively processor intensive and you do not want that to happen everytime someone looks at your picture. Again, you have to write the code for that yourself I'm afraid.

Re: Need an advice

Posted: Fri Mar 24, 2006 1:35 pm
by URAN
I think it should be something like:


text, text, text, text,
"


I will try to do it, but what it should be? A function at the /plugin/ folder? I need more information

Re: Need an advice

Posted: Fri Mar 24, 2006 2:02 pm
by cyberman
Perhaps it would be possible to modify an existing tool like pipictures ...

Re: Need an advice

Posted: Sat Mar 25, 2006 4:34 am
by URAN
Or maybe I should modify FCKeditorX ? Add function "popup big pic", to automatically paste code like:

Code: Select all

<a OnClick="window.open
('/lstock-images/175-1/001.jpg', '', 'top=0, left=0, width=670, height=610, directories=no,toolbar=no,status=no, location=no,resizable=no,menubar=no,scrollbars=yes');
 return false;" 
target=_blank 
href="/lstock-images/175-1/001.jpg">
<img src="/lstock-images/175-1/small/001.jpg" width="120" height="90" alt="" border="1">
</a>

Re: Need an advice

Posted: Mon Mar 27, 2006 3:43 pm
by Piratos
You can use or change it for your use this smarty - plugin from me, that can make watermarks:

Code: Select all

<?
function smarty_function_picturepopup($params, &$smarty)
{
  $dependent = isset($params['dependent']) ? $params['dependent']:'no';
  $height = isset($params['height']) ? $params['height']:200;
  $hotkeys = isset($params['hotkeys']) ? $params['hotkeys']:'true';
  $innerheight = isset($params['innerheight']) ? $params['innerheight']:200;
  $innerwidth = isset($params['innerwidth']) ? $params['innerwidth']:200;
  $left =isset($params['left']) ? $params['left']:200;
  $location =isset($params['location']) ? $params['location']:'no';
  $menubar =isset($params['menubar']) ? $params['menubar']:'no';
  $resizeable =isset($params['resizeable']) ? $params['resizelable']:'no';
  $screenx =isset($params['screenx']) ? $params['screenx']:200;
  $screeny =isset($params['screeny']) ? $params['screeny']:200;
  $scrollbars =isset($params['scrollbars']) ? $params['scrollbars']:'no';
  $status =isset($params['status']) ? $params['status']:'no';
  $toolbar =isset($params['toolbar']) ? $params['toolbar']:'no';
  $top =isset($params['top']) ? $params['top']:200;
  $width =isset($params['width']) ? $params['width']:200;
  
  $image =isset($params['image']) ? $params['image']:'';
  $wz =isset($params['wz']) ? $params['wz']:'';
  if ($image =='') return;
  if (!is_file($image)) return;
  $infos_img = getimagesize($image); // 0 =Breite, 1=Höhe, 2= (1 = GIF, 2 = JPG, 3 = PNG, SWF = 4) 3 Höhe und Weite als HTML
  if ($wz <>'') $infos_wz = getimagesize($wz); else $infos_wz=false;
  $width = $infos_img[0];
  $height = $infos_img[1];
  if(!in_array($infos_img[2], array(2,3))) return;   // png oder jpg
  $tmpfname = $smarty->cache_dir . "PicturePopWasserzeichen_".basename($image);
  if (!$infos_wz === false && !is_file($tmpfname))
  {
    if(!in_array($infos_wz[2], array(2,3))) return;  // png oder jpg
    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);
    //echo $pos_x.'<br />';echo $pos_y;
    if($infos_img[2] == 2)
        $img_image = imagecreatefromjpeg($image);
    if($infos_img[2] == 3)
        $img_image = imagecreatefrompng($image);
    if($infos_wz[2] == 2)
        $img_watermark = imagecreatefromjpeg($wz);
    if($infos_wz[2] == 3)
    $img_watermark = imagecreatefrompng($wz);
    imagealphablending($img_image, true);
    imagealphablending($img_watermark, true);
    imagecolortransparent($img_watermark, imagecolorat($img_watermark, 0,0));
    imagecopymerge($img_image, $img_watermark, $pos_x, $pos_y, 0, 0, $infos_wz[0], $infos_wz[1], 100);
    if(strtolower(substr($tmpfname, -3)) == "png") {
        if(!imagepng($img_image, $tmpfname)) return;

    } else
    {
        if(!imagejpeg($img_image, $tmpfname)) return;

    }
  }

    if (!is_file($tmpfname)) $tmpfname = $image;

  echo '<__script__ type="text/javascript">
      F1 = window.open("'.$tmpfname.'", "PicturePopUp", "width='.$width.',height='.$height.',left='.$left.',top='.$top.'");</__script>';

}

Re: Need an advice

Posted: Tue Mar 28, 2006 5:51 am
by URAN
Piratos, thank you. I`ll try to apply it right now :) Just do not understand how to apply it ?

Re: Need an advice

Posted: Tue Mar 28, 2006 10:40 am
by Piratos
That plugin is a smarty plugin (not a cmsms plugin) and so you should copy it to lib/smarty/plugins folder.
For you it is simpler to change the output of the plugin from

echo ' F1 = window.open("'.$tmpfname.'", "PicturePopUp", "width='.$width.',height='.$height.',left='.$left.',top='.$top.'");';

to this

echo 'F1 = window.open("'.$tmpfname.'", "PicturePopUp", "width='.$width.',height='.$height.',left='.$left.',top='.$top.'");';

After changing you can use it as example as follow:





image - the path and name of the original big picture without watermark
wz  - the path and name of the watermark picture

Remark: only jpg or png format

That plugin merges both pictures to a new one if it not exists and write it to the smarty- caching-folder.

The wz - image must exists - you should create it.

if you set no wz - image the original picture was shown.
if you always use the same watermark you can change this

$wz =isset($params['wz']) ? $params['wz']:'';

to

$wz =isset($params['wz']) ? $params['wz']:'images/my_default_watermark.png';

So the wz parameter are never needed.

you can set all popup related parameters, but now in the output are only left and top. width and height comes from the dimensions of the big picture.
if you need the other parameters, you must expand the output string.

you can use this plugin in templates of my plugin pipictures.

Re: Need an advice

Posted: Tue Mar 28, 2006 10:44 am
by URAN
Thank you, it looks clear, will try now

Re: Need an advice

Posted: Tue Mar 28, 2006 11:50 am
by Piratos
instead of form you can use

Code: Select all

<a href='#' onClick='{picturepopup image="images/image0.jpg" wz="images/wz.png"}'>BigPicture</a>

Re: Need an advice

Posted: Tue Mar 28, 2006 11:55 am
by URAN
Piratos wrote: instead of form you can use

Code: Select all

<a href='#' onClick='{picturepopup image="images/image0.jpg" wz="images/wz.png"}'>BigPicture</a>
Great! It even more suitable for me!

Re: Need an advice

Posted: Tue Mar 28, 2006 1:18 pm
by URAN
Partically it works. Can not understand what is wrong. Pop up window is appear, but inside there is no images, only text of 404 error - Not found...

When I creating the page, I typed in this code:








When I look into the source code of my page, I see this:







Now it`s clear why image is not found : "/home/uran/public_html/fit/tmp/cachePicturePopWasserzeichen_honda_fit_photo01.jpg".

Original image is in the "uploads/images/desc/photo/honda_fit_photo01.jpg"

How to solve it?

Re: Need an advice

Posted: Tue Mar 28, 2006 1:57 pm
by Piratos
$tmpfname = $smarty->cache_dir . "PicturePopWasserzeichen_".basename($image);
The reason may be, that there is cache_dir without ending slash.

change it at first to:
$tmpfname = $smarty->cache_dir . "/PicturePopWasserzeichen_".basename($image);
and test it

if it not works change it to:

$tmpfname = '/home/uran/public_html/fit/tmp/cache/'."PicturePopWasserzeichen_".basename($image);

The Watermarkfunction is ok:



[attachment deleted by admin]

Re: Need an advice

Posted: Tue Mar 28, 2006 4:03 pm
by URAN
Yahooo!!!! :D  I works!

Re: Need an advice

Posted: Tue Mar 28, 2006 5:37 pm
by URAN
It`s me again, have some new questions :)

1. Why I can not use PNG-24 mode for watermark, only PNG-8. I want to apply 50% transparent watermark, so it become impossible - if I use PNG-24, at the output window I see black strip instead of trasparent image.

2. How to adjust watermark position on image ? Would like to place it at the bottom right corner.

3. How to add HTML-code around image ? I would like to add ability to close image by left-clicking on it with this command: