Keyword

I'm just trying to add a png watermark on image upload

  • alexandre barbe
  • alexandre barbe's Avatar Topic Author
  • Offline
  • New Member
More
15 years 3 weeks ago #84302 by alexandre barbe
Hi there, like the title said, i try to put a watermark on my images, but with no success... I put : $handle->image_watermark = 'path to the watermark' in com_k2 > models > item.php where my small image is handle, but its a fail, no watermark at all. Anyone have a clue ?

Please Log in or Create an account to join the conversation.

  • alexandre barbe
  • alexandre barbe's Avatar Topic Author
  • Offline
  • New Member
More
15 years 3 weeks ago #84303 by alexandre barbe
Replied by alexandre barbe on topic I'm just trying to add a png watermark on image upload
I think i'm sadly the only one who try this :/
This is very strange, when i add a reflection ( $handle->image_reflection_height = '25%';) it work
when i add rotate or crop ($handle->image_rotate = 90; $handle->image_crop = array(50,40,30,20);) it work, there were only the watermark who doesn't work...

Please Log in or Create an account to join the conversation.

More
14 years 8 months ago #84304 by BFL
Did you find an answer?

Please Log in or Create an account to join the conversation.

  • JTJ van Loendersloot
  • JTJ van Loendersloot's Avatar
  • Offline
  • New Member
More
14 years 8 months ago #84305 by JTJ van Loendersloot
Replied by JTJ van Loendersloot on topic I'm just trying to add a png watermark on image upload
You have to put in the full path to your watermark.png.

$handle->image_watermark '/home/{user}/public_html/...../watermark.png' if you are on a linux server.

Please Log in or Create an account to join the conversation.

More
14 years 6 months ago #84306 by BBC
Could you explain a little bit more that ? I am trying to get it to work with Wamp (Windows).
Tried everything but it wont work.

Please Log in or Create an account to join the conversation.

  • JTJ van Loendersloot
  • JTJ van Loendersloot's Avatar
  • Offline
  • New Member
More
14 years 6 months ago #84307 by JTJ van Loendersloot
Replied by JTJ van Loendersloot on topic I'm just trying to add a png watermark on image upload
I'm have a debian server, so you should ask someone else. I use the complete base path.

 

Put $handle->image_watermark = 'path to the watermark' in administrator > components > com_k2 > models > item.php

 

So you get something like this:

around line 213;

 

 

                //XLarge image



                //location of the watermark

                $handle->image_watermark = '/home/*************/public_html/images/stories/watermark/watermark_xl.png';



                //position of the watermark

                $handle->image_watermark_position = 'BR';  



                $handle->image_resize = true;

                $handle->image_ratio_y = true;

                $handle->image_convert = 'jpg';

                $handle->jpeg_quality = $params->get('imagesQuality');

                $handle->file_auto_rename = false;

                $handle->file_overwrite = true;

                $handle->file_new_name_body = $filename.'_XL';

                if (JRequest::getInt('itemImageXL')) {

                    $imageWidth = JRequest::getInt('itemImageXL');

                } else {

                    $imageWidth = $params->get('itemImageXL', '800');

                }

                $handle->image_x = $imageWidth;

                $handle->Process($savepath);

 

Please Log in or Create an account to join the conversation.

More
14 years 5 months ago #84308 by BBC
Developers did something in new 2.5 SVN version.

Regarding watermark and images crop options.

 

So, it should be easy now. Just to make it to settings in xml files. :)

Please Log in or Create an account to join the conversation.

More
14 years 4 months ago #84309 by bunglehaze
Any idea what the watermark setting is in 2.5SVN? I cannot find anything about this in my install...

Please Log in or Create an account to join the conversation.

More
14 years 4 months ago #84310 by BBC
There is nothing in settings. Search forum how to fix it in files.

Please Log in or Create an account to join the conversation.

More
14 years 4 months ago #84311 by bunglehaze
There is already a fix in this thread which works perfectly well, I asked you to elaborate on your quote below as you seem to imply that something has been changed to make it simpler. How can you make statements like this, if you do not know the changes yourself?


Developers did something in new 2.5 SVN version.

Regarding watermark and images crop options.

 

So, it should be easy now. Just to make it to settings in xml files. :)

Please Log in or Create an account to join the conversation.

More
14 years 4 months ago #84312 by BBC
Don´t know. Wait for 2.5 stable.

Can give that statement because i compared all changes with Beyond Compare.

 

bunglehaze said:

There is already a fix in this thread which works perfectly well, I asked you to elaborate on your quote below as you seem to imply that something has been changed to make it simpler. How can you make statements like this, if you do not know the changes yourself?


Developers did something in new 2.5 SVN version.

Regarding watermark and images crop options.

 

So, it should be easy now. Just to make it to settings in xml files. :)

Please Log in or Create an account to join the conversation.

More
14 years 4 months ago #84313 by bunglehaze
That still makes absolutely no sense at all - fair enough if you have a qualified answer about what you are posting about but it is of no use to anyone to post up a vague statement like you can add to xml files and it will be easy if you have no basis for where or how changes have been made. For less experienced visitors to this site posts like that tend to cause more confusion and problems IMHO.

 

I have no need to wait for 2.5 stable because my site is running 2.5SVN and I am happily working through the modifications I need for my site which other than a performance issue that is carried over from 2.4.1 is working just fine, there have been a fair few changes under the hood but nothing points to a watermark function being added to K2 itself from what I can see.


BBC said:

Don´t know. Wait for 2.5 stable.

Can give that statement because i compared all changes with Beyond Compare.

 

bunglehaze said:

There is already a fix in this thread which works perfectly well, I asked you to elaborate on your quote below as you seem to imply that something has been changed to make it simpler. How can you make statements like this, if you do not know the changes yourself?


Developers did something in new 2.5 SVN version.

Regarding watermark and images crop options.

 

So, it should be easy now. Just to make it to settings in xml files. :)

Please Log in or Create an account to join the conversation.

More
14 years 2 months ago #84314 by Jordan Ivanov
Replied by Jordan Ivanov on topic I'm just trying to add a png watermark on image upload
This handles only the item image, but doesn't work for the gallery images.

I added $handle->image_watermark on line 440 and line 450, but no success.

Does anyone know how can I add watermark to the gallery images?

Please Log in or Create an account to join the conversation.

More
14 years 2 months ago #84315 by Jordan Ivanov
Replied by Jordan Ivanov on topic I'm just trying to add a png watermark on image upload
This handles only the item image, but doesn't work for the gallery images.
I added $handle->image_watermark on few other places, but no success.
Can anyone help me to add watermark to gallery images?

Please Log in or Create an account to join the conversation.

More
14 years 2 months ago #84316 by Jordan Ivanov
Replied by Jordan Ivanov on topic I'm just trying to add a png watermark on image upload
Any suggestions please

Please Log in or Create an account to join the conversation.

  • JTJ van Loendersloot
  • JTJ van Loendersloot's Avatar
  • Offline
  • New Member
More
14 years 2 months ago #84317 by JTJ van Loendersloot
Replied by JTJ van Loendersloot on topic I'm just trying to add a png watermark on image upload
Look in  administrator > components > com_k2 > models > item.php and search for :

//Gallery

 

Between:

JFile::delete($savepath.DS.$handle->file_dst_name); 

$handle->Clean();

 

HERE!!>>>>

 

and:} else {

 $mainframe->redirect('index.php?option=com_k2&view=items', $handle->error, 'error');

 

Place this code:

// Digitechs add watermark !!

               if ($dir = opendir($savepath.DS.$row->id)) {

         while (false !== ($file = readdir($dir))) {

                  $handle = new Upload ($savepath.DS.$row->id.'/'.$file);

         $handle->allowed = array('image/*'); 

         $handle->image_watermark = '/home/******/public_html/<--absolute path to watermark-->watermark.png';

          $handle->image_watermark_position = 'BR';

         $handle->file_auto_rename = false;        

          $handle->file_overwrite = true;

         $handle->Process($savepath.DS.$row->id);

     }     closedir($dir);

}

 


Good luck.

Please Log in or Create an account to join the conversation.

More
14 years 2 months ago #84318 by Jordan Ivanov
Replied by Jordan Ivanov on topic I'm just trying to add a png watermark on image upload
Great Justin!

After two evenings of tumbling in the dark, something like this was in my ToDo list. You saved me big headache.

Tonight I'll try it.

Thank you very much.

Please Log in or Create an account to join the conversation.

More
14 years 2 months ago #84319 by Jordan Ivanov
Replied by Jordan Ivanov on topic I'm just trying to add a png watermark on image upload
Thanks again Justin.

I didn't succeed from the first try, I still got white screen on item save.

I did some little improvements and now it works as I wanted.

I increased max_execution_time and max_input_time in php.ini :

max_input_time = 300max_execution_time = 90

Also I added image_resize, so finally the code looks like this:

if ($dir = opendir($savepath.DS.$row->id)) { while (false !== ($file = readdir($dir))) {
$handle = new Upload ($savepath.DS.$row->id.'/'.$file);
$handle->allowed = array('image/*');
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->image_resize = true;
$handle->image_x = 1024;
$handle->image_ratio_y = true;
$handle->image_watermark = '/home/user/public_html/images/watermark.png';
$handle->image_watermark_position = 'BR';
$handle->image_convert = 'jpg';
$handle->jpeg_quality = 85;
$handle->Process($savepath.DS.$row->id);
$handle->Clean();
}
closedir($dir);
}


It will be good if JoomlaWorks include it in K2.

Please Log in or Create an account to join the conversation.

  • JTJ van Loendersloot
  • JTJ van Loendersloot's Avatar
  • Offline
  • New Member
More
14 years 2 months ago #84320 by JTJ van Loendersloot
Replied by JTJ van Loendersloot on topic I'm just trying to add a png watermark on image upload
Glad it worked out for you.

Please Log in or Create an account to join the conversation.

More
14 years 2 weeks ago #84321 by innocence
Hi Jordan.

You are clearly not the one who needs to implement the watermark feature in K2. I´m desperately needing to implement this feature.

I have tried the code you published here but with no success! I see your code working in www.alcatraz.bg and I just got tired of trying to do the same, I don´t know what else to do!

 

I´m testing on a local server (AppServ 2.5.10 under Windows XP). Joomla! v1.5.23, latest K2 stable release...

 

Could you please help me in any way? Could you please post or send me your item.php file you are using on alcatraz.bg ?

 

I´ll be just here waiting for your answer. Sorry about my english! And thanks in advance!!!



 

Jordan Ivanov said:

Thanks again Justin.

I didn't succeed from the first try, I still got white screen on item save.

I did some little improvements and now it works as I wanted.

I increased max_execution_time and max_input_time in php.ini :

max_input_time = 300max_execution_time = 90

Also I added image_resize, so finally the code looks like this:

if ($dir = opendir($savepath.DS.$row->id)) { while (false !== ($file = readdir($dir))) { $handle = new Upload ($savepath.DS.$row->id.'/'.$file);
$handle->allowed = array('image/*');
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->image_resize = true;
$handle->image_x = 1024;
$handle->image_ratio_y = true;
$handle->image_watermark = '/home/user/public_html/images/watermark.png';
$handle->image_watermark_position = 'BR';
$handle->image_convert = 'jpg';
$handle->jpeg_quality = 85;
$handle->Process($savepath.DS.$row->id);
$handle->Clean();
}
closedir($dir);
}


It will be good if JoomlaWorks include it in K2.

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum