hi i got all types of errors trying to add this watermark
url: http://liwzy.isgreat.org/watermark.png
please someone give the code cuz i can`t figure where exatly to put the image path
cuz i get no "url acces" error ... free host .. or is just not showing..
url: http://liwzy.isgreat.org/watermark.png
please someone give the code cuz i can`t figure where exatly to put the image path
cuz i get no "url acces" error ... free host .. or is just not showing..
Check your config.php is that got the right image path in it?
OpenCart Theme Options - See All My Extensions - OpenCart Themes and Mods
Just delete yout images cache directory ...Is it possible to watermark existing images,
isn't a watermark, with a right click, I can backup the image without the watermark, I think it's a bad ideaand to do so with an actual watermark rather than just a div overlay
Nicolas
Wow, I'll just remove the cache. Great - thank you.
Exactly.acidline wrote:isn't a watermark, with a right click, I can backup the image without the watermark, I think it's a bad ideaand to do so with an actual watermark rather than just a div overlay
For those that need to position the watermark on the center of the image, try this:
1. open system/library/image.php, and around line 85 find this code:
and replace it with the following code:
2. open file system/helper/image.php and find this code (around line 12):
and replace it with the following:
Works for me fine, even for thumbnails
1. open system/library/image.php, and around line 85 find this code:
Code: Select all
public function watermark($file, $position = 'bottomright') {
//$watermark = $this->create($file);
$watermark = imagecreatefrompng($file);
$watermark_width = imagesx($watermark);
$watermark_height = imagesy($watermark);
switch($position) {
case 'topleft':
$watermark_pos_x = 0;
$watermark_pos_y = 0;
break;
case 'topright':
$watermark_pos_x = (($this->info['width']) * 0.2);
$watermark_pos_y = $this->info['height'] * 0.2;
break;
case 'bottomleft':
$watermark_pos_x = 0;
$watermark_pos_y = $this->info['height'] - $watermark_height;
break;
case 'bottomright':
$watermark_pos_x = $this->info['width'] - $watermark_width;
$watermark_pos_y = $this->info['height'] - $watermark_height;
break;
}
and replace it with the following code:
Code: Select all
public function watermark($file, $position = 'bottomright') {
//$watermark = $this->create($file);
$watermark = imagecreatefrompng($file);
$watermark_width = imagesx($watermark);
$watermark_height = imagesy($watermark);
switch($position) {
case 'topleft':
$watermark_pos_x = 0;
$watermark_pos_y = 0;
break;
case 'topright':
$watermark_pos_x = (($this->info['width']) * 0.2);
$watermark_pos_y = $this->info['height'] * 0.2;
break;
case 'bottomleft':
$watermark_pos_x = 0;
$watermark_pos_y = $this->info['height'] - $watermark_height;
break;
case 'bottomright':
$watermark_pos_x = $this->info['width'] - $watermark_width;
$watermark_pos_y = $this->info['height'] - $watermark_height;
break;
case 'center':
$watermark_pos_x = ($this->info['width']- $watermark_width)/2;
$watermark_pos_y = ($this->info['height']- $watermark_height)/2;
break;
}
2. open file system/helper/image.php and find this code (around line 12):
Code: Select all
$image->watermark(HTTP_IMAGE . 'watermark.png', 'bootomright');
Code: Select all
$image->watermark(HTTP_IMAGE . 'watermark.png', 'center');
I was looking for instructions to create a good watermark on the images, but I nearly got lost between the threads in this forum on how to make it work.
Therefore I decided to put all the suggestions that I found useful for me.
The code below includes watermark method fix (thanks to acidline!) useful code enhancements that allow to center watermark in the image (thanks to dedurus!) and also define the minimum image size for which the watermark will be applied (that was added by myself).
These watermarks are applied upon image resize, so the watermarks are not added as an overlay but as a part of original image (option suggested by JAY6390 in http://forum.opencart.com/viewtopic.php?t=16533). This solves the issue that original image can still be fetched without the watermark.
These instructions are valid for Opencart 1.4.9.1 and 1.4.9.2 (I did this on v. 1.4.9.2)
1. Create PNG watermark, name it as watermark.png and copy it to image/ folder of your Opencart installation (yes, it works fine with PNG files).
2. Now edit 2 PHP files
3. The first file: system/library/image.php
Go to lines 93-121 and you will see the following code:
You have to replace this code with the code below (the code includes a watermark method fix described by acidline and option to center watermark in the image described by dedurus in this thread above):
4. Second file to edit is catalog/model/tool/image.php
Go to line 27 and you will see the follwing line:
Right after this line add the following code:
In the code above you can define desired position of the watermark (topleft, topright, bottomleft, bottomright or center).
You can also define minimum width or height of your image to which the watermark will be added (if you want watermarks appear even on thumbnails, put 0)
5. Final step: delete all data in folder image/cache/data in order to have the images recreated with watermarks.
That's it!
I hope I helped to those who have problems making watermarks work.
Therefore I decided to put all the suggestions that I found useful for me.
The code below includes watermark method fix (thanks to acidline!) useful code enhancements that allow to center watermark in the image (thanks to dedurus!) and also define the minimum image size for which the watermark will be applied (that was added by myself).
These watermarks are applied upon image resize, so the watermarks are not added as an overlay but as a part of original image (option suggested by JAY6390 in http://forum.opencart.com/viewtopic.php?t=16533). This solves the issue that original image can still be fetched without the watermark.
These instructions are valid for Opencart 1.4.9.1 and 1.4.9.2 (I did this on v. 1.4.9.2)
1. Create PNG watermark, name it as watermark.png and copy it to image/ folder of your Opencart installation (yes, it works fine with PNG files).
2. Now edit 2 PHP files
3. The first file: system/library/image.php
Go to lines 93-121 and you will see the following code:
Code: Select all
public function watermark($file, $position = 'bottomright') {
$watermark = $this->create($file);
$watermark_width = imagesx($watermark);
$watermark_height = imagesy($watermark);
switch($position) {
case 'topleft':
$watermark_pos_x = 0;
$watermark_pos_y = 0;
break;
case 'topright':
$watermark_pos_x = $this->info['width'] - $watermark_width;
$watermark_pos_y = 0;
break;
case 'bottomleft':
$watermark_pos_x = 0;
$watermark_pos_y = $this->info['height'] - $watermark_height;
break;
case 'bottomright':
$watermark_pos_x = $this->info['width'] - $watermark_width;
$watermark_pos_y = $this->info['height'] - $watermark_height;
break;
}
imagecopy($this->image, $watermark, $watermark_pos_x, $watermark_pos_y, 0, 0, 120, 40);
imagedestroy($watermark);
}
Code: Select all
public function watermark($file, $position = 'bottomright') {
//Pb ! you don't work on the true object => you must modify the "create" method ($mime = $this->info['mime']; it's work only if we have the same image format !
//$watermark = $this->create($file);
//Prefer PNG files => it's not optimized but it's work
$watermark = imagecreatefrompng($file);
$watermark_width = imagesx($watermark);
$watermark_height = imagesy($watermark);
switch($position) {
case 'topleft':
$watermark_pos_x = 0;
$watermark_pos_y = 0;
break;
case 'topright':
$watermark_pos_x = $this->info['width'] - $watermark_width;
$watermark_pos_y = 0;
break;
case 'bottomleft':
$watermark_pos_x = 0;
$watermark_pos_y = $this->info['height'] - $watermark_height;
break;
case 'bottomright':
$watermark_pos_x = $this->info['width'] - $watermark_width;
$watermark_pos_y = $this->info['height'] - $watermark_height;
break;
case 'center':
$watermark_pos_x = ($this->info['width']- $watermark_width)/2;
$watermark_pos_y = ($this->info['height']- $watermark_height)/2;
break;
}
imagecopy($this->image, $watermark, $watermark_pos_x, $watermark_pos_y, 0, 0, $watermark_width, $watermark_height);
imagedestroy($watermark);
}
Go to line 27 and you will see the follwing line:
Code: Select all
$image = new Image(DIR_IMAGE . $old_image);
Code: Select all
if ($width > 400 || $height > 300) {
$image->watermark(DIR_IMAGE . 'watermark.png', 'center');
}
You can also define minimum width or height of your image to which the watermark will be added (if you want watermarks appear even on thumbnails, put 0)
5. Final step: delete all data in folder image/cache/data in order to have the images recreated with watermarks.
That's it!
I hope I helped to those who have problems making watermarks work.
Last edited by siuksliadeze on Fri Nov 26, 2010 3:33 am, edited 2 times in total.
How to add the watermark image to all images
I like to add the mark to all images sizes can that be possible?
I using 1.4.9.2
Thank you
to all the experts who take the time to read this post
God Bless you all.
nice work Opencart team
I like to add the mark to all images sizes can that be possible?
I using 1.4.9.2
Thank you
to all the experts who take the time to read this post
God Bless you all.
nice work Opencart team
That's super easy, either put 0's in IF statement or just drop the IF statement, i.e. instead of this piece of codemoreno13 wrote:How to add the watermark image to all images
I like to add the mark to all images sizes can that be possible?
I using 1.4.9.2
Thank you
to all the experts who take the time to read this post
God Bless you all.
nice work Opencart team
Code: Select all
if ($width > 400 || $height > 300) {
$image->watermark(DIR_IMAGE . 'watermark.png', 'center');
}
Code: Select all
$image->watermark(DIR_IMAGE . 'watermark.png', 'center');
I found a Watermark code online.
So i combined into my Opencart.
NO NEED OPENCART BUILTIN WATERMARK() FUNCTION.
NO NEED ANY IMAGE FILE FOR WATERMARK.
JUST USE TEXT WATERMARKS.
1. Find this code in the file 'system/library/image.php'
(Its in the save() function)
2. Add following piece of codes AFTER.
Enjoy!
Regards,
Arkar
arkarwmh@gmail.com
So i combined into my Opencart.
NO NEED OPENCART BUILTIN WATERMARK() FUNCTION.
NO NEED ANY IMAGE FILE FOR WATERMARK.
JUST USE TEXT WATERMARKS.
1. Find this code in the file 'system/library/image.php'
(Its in the save() function)
Code: Select all
if ($extension == 'jpeg' || $extension == 'jpg') {
Code: Select all
$width = imagesx($this->image);
$height = imagesy($this->image);
$statement = 'Copyright to www.yourwebsite.com';
$fontsize = 2;
foreach (range($fontsize, 1) as $_fontsize) {
$fontw = imagefontwidth($_fontsize);
$fullw = strlen($statement) * $fontw;
if ($fullw + 4 <= $width) {
break;
}
}
$fonth = imagefontheight($_fontsize);
$black = imagecolorallocate($this->image, 0, 0, 0);
$gray = imagecolorallocate($this->image, 200, 200, 200);
$white = imagecolorallocate($this->image, 255, 255, 255);
// imagefilledrectangle($this->image, // The graphics object to draw on
// $width - $fullw - 4, // The X value of upper left corner
// $height - $fonth - 4, // The Y value of upper left corner
// $width, // The X value of lower right corner
// $height, // The Y value of lower right corner
// $gray); // The color
imagestring($this->image, // The graphics object to draw on
$fontsize, // The font size to use.
$width - $fullw - 2, // X value of upper left corner
$height - $fonth - 2, // Y value of upper left corner
$statement, // The text to print
$gray); // The color to do it with.
Regards,
Arkar
arkarwmh@gmail.com
siuksliadeze, thanks a million! I'm using this on a new store - Fitutex (traditional Indian ethnic wear) - the best part is, since the source of the watermark in .png, I can have some text-effects on the copyright notice, and that integrates with the new generated image directly (well almost, this side-effect is not perfect)! This is definitely much more convenient that hacking at every image in Photoshop before upload
The only issue I noticed was, if you upload a PNG 24 file, it does not save properly. The transparency is lost, and some additional disturbance is getting added to the image. But PNG 8 files work fine.
Thanks once again...
The only issue I noticed was, if you upload a PNG 24 file, it does not save properly. The transparency is lost, and some additional disturbance is getting added to the image. But PNG 8 files work fine.
Thanks once again...
siuksliadeze thanks a lot!
It's working great on 1.4.8 too.
This is only working method to fix watermark on Opencart 1.4.8 - I tested many, many "tips and tricks" and only this give my satisfaction.
In 3 minutes - super
Best regards!
PS
in any case you don't forget to backup files from the topic before mod
It's working great on 1.4.8 too.
This is only working method to fix watermark on Opencart 1.4.8 - I tested many, many "tips and tricks" and only this give my satisfaction.
In 3 minutes - super
Best regards!
PS
in any case you don't forget to backup files from the topic before mod
arkarwmh wrote:I found a Watermark code online.
So i combined into my Opencart.
NO NEED OPENCART BUILTIN WATERMARK() FUNCTION.
NO NEED ANY IMAGE FILE FOR WATERMARK.
JUST USE TEXT WATERMARKS.
I haven't tried it yet, but does it add the watermark text on every images (thumbnails, and big images), or just on the "pop-up product images"? Can I choose the size of images I want to be watermarked?
Thanks!
I have met the same problem, i want the products images with watermark when they are zoomed. but i don't know how to do it
ebuybeauty wrote:I have met the same problem, i want the products images with watermark when they are zoomed. but i don't know how to do it
I did it (or better, someone did it for me :-)). This is the code:
Code: Select all
$fontfile = '/path-of-your-font/yourfont.TTF';
$rotation = 30;
$width = imagesx($this->image);
$height = imagesy($this->image);
$statement = 'Copyright by.......;
if ($width > 500) {
$fontsize = 50;
} else if ($width > 200) {
$fontsize = 15;
} else if ($width > 50) {
$fontsize = 8;
} else {
$fontsize = 0;
}
if ($fontsize>0) {
//imagealphablending($this->image, true);
//imagesavealpha($this->image, true);
$wmColor = imagecolorallocatealpha($this->image, 150, 150, 150, 90);
$wmDim = imagettfbbox ( $fontsize, $rotation, $fontfile , $statement );
imagettftext( $this->image , $fontsize, $rotation, ($width - $wmDim[2])/2, ($height - $wmDim[3])/2 , $wmColor, '/path-of-your-font/yourfont.TTF' , $statement );
Hope this can help!
[quote="siuksliadeze"]I was looking for instructions to create a good watermark on the images, but I nearly got lost between the threads in this forum on how to make it work.
Therefore I decided to put all the suggestions that I found useful for me.
Thank you very much. Perfect explain. It works with Version 1.4.9.4 aswell.
Therefore I decided to put all the suggestions that I found useful for me.
Thank you very much. Perfect explain. It works with Version 1.4.9.4 aswell.
I Love Open Cart : )
http://www.stabilitees.com
Who is online
Users browsing this forum: Amazon [Bot], Google [Bot] and 75 guests