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);
}