- Posts: 4
COMMUNITY FORUM
- Forum
- K2 Community Forum
- English K2 Community
- I'm just trying to add a png watermark on image upload
I'm just trying to add a png watermark on image upload
- alexandre barbe
-
Topic Author
- Offline
- New Member
Please Log in or Create an account to join the conversation.
- alexandre barbe
-
Topic Author
- Offline
- New Member
- Posts: 4
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.
- BFL
-
- Offline
- New Member
- Posts: 5
Please Log in or Create an account to join the conversation.
- JTJ van Loendersloot
-
- Offline
- New Member
- Posts: 4
$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.
- BBC
-
- Offline
- Platinum Member
- Posts: 663
Tried everything but it wont work.
Please Log in or Create an account to join the conversation.
- JTJ van Loendersloot
-
- Offline
- New Member
- Posts: 4
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.
- BBC
-
- Offline
- Platinum Member
- Posts: 663
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.
- bunglehaze
-
- Offline
- Elite Member
- Posts: 168
Please Log in or Create an account to join the conversation.
- BBC
-
- Offline
- Platinum Member
- Posts: 663
Please Log in or Create an account to join the conversation.
- bunglehaze
-
- Offline
- Elite Member
- Posts: 168
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.
- BBC
-
- Offline
- Platinum Member
- Posts: 663
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.
- bunglehaze
-
- Offline
- Elite Member
- Posts: 168
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.
- Jordan Ivanov
-
- Offline
- New Member
- Posts: 10
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.
- Jordan Ivanov
-
- Offline
- New Member
- Posts: 10
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.
- Jordan Ivanov
-
- Offline
- New Member
- Posts: 10
Please Log in or Create an account to join the conversation.
- JTJ van Loendersloot
-
- Offline
- New Member
- Posts: 4
//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.
- Jordan Ivanov
-
- Offline
- New Member
- Posts: 10
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.
- Jordan Ivanov
-
- Offline
- New Member
- Posts: 10
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
-
- Offline
- New Member
- Posts: 4
Please Log in or Create an account to join the conversation.
- innocence
-
- Offline
- New Member
- Posts: 16
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.
- Forum
- K2 Community Forum
- English K2 Community
- I'm just trying to add a png watermark on image upload