Watermark after image resize ?

  • Posts: 16
  • Thank you received: 0
9 years 2 months ago #212543

-- HikaShop version -- : 2.5.0
-- Joomla version -- : 3.4.3
-- PHP version -- : 5.4

Hi,
I have to use the watermark feature since I'm trying not to let other people use my product photos on their websites.
As I see it: I upload an image, the watermark is applied, the image is resized. But what if the size of my images is not always the same? Isn't this the point of resize feature in a script? Sure is. But with bigger images my watermark becomes so small I can barely distinguish it.
So this leads to inevitable preprocessing, which is really annoying, especially if you need to do it on daily basis.

Do I understand this correctly, that there is no way I can protect my images with watermark feature, if the uploaded images size varies greatly?
If no, is it possible to make the script apply watermark after resize with code modification? Maybe you can point me in the right direction, where should I start looking for the relevant part of the code?

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
9 years 2 months ago #212561

Hi,

What people do normally in such case is that they use a transparent watermark as big as the biggest image in the shop, and repeat the image of the logo (or whatever) on that transparent image so that regardless of the image size, the watermark will be visible enough.

If you want to modify the code handling the processing of the watermark for the images, you want to edit the file administrator/components/com_hikashop/helpers/image.php and look at the _resizeImage and more specifically that code:

if(!empty($watermark_path)){
			list($wm_width,$wm_height) = getimagesize($watermark_path);
			$padding = 3;
			$dest_x = $newWidth - $wm_width - $padding;
			if($dest_x < 0) $dest_x = 0;
			$dest_y = $newHeight - $wm_height - $padding;
			if($dest_y < 0) $dest_y = 0;
			$trnprt_color=null;
			if(in_array($extension,array('gif','png'))){
				$trnprt_indx = imagecolortransparent($img);
				if ($trnprt_indx >= 0) {
					$trnprt_color = imagecolorsforindex($img, $trnprt_indx);
				}
			}
			imagealphablending($thumb, false);
			imagealphablending($watermark, false);
			$this->imagecopymerge_alpha($thumb, $watermark, $dest_x, $dest_y, 0, 0, $wm_width, $wm_height, (int)$config->get('opacity',0),$trnprt_color);

			imagedestroy($watermark);
		}

The following user(s) said Thank You: sr9yar

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

Time to create page: 0.034 seconds
Powered by Kunena Forum