
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..

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
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
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;
}
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;
}
Code: Select all
$image->watermark(HTTP_IMAGE . 'watermark.png', 'bootomright');
Code: Select all
$image->watermark(HTTP_IMAGE . 'watermark.png', 'center');
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);
}
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');
}
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');
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.
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.
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
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 );
I Love Open Cart : )
http://www.stabilitees.com
Users browsing this forum: No registered users and 53 guests