does it work on v1.5.1.x? thanksarkarwmh 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.
1. Find this code in the file 'system/library/image.php'
(Its in the save() function)2. Add following piece of codes AFTER.Code: Select all
if ($extension == 'jpeg' || $extension == 'jpg') {
Enjoy!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
[Edit] I tested, it works on v1.5.1.2.
but the words is right on the left corner. How to put the watermark in the center ?