if($imgsize['mime']=='image/png'){
$src = ImageCreateFromPng($image);
$dst = ImageCreateTrueColor($tn_width, $tn_height);
$black = imagecolorallocate($dst, 0, 0, 0);
imagecolortransparent($dst, $black);
imagealphablending($dst, false); // one
imageSaveAlpha($dst, true); // two
imagecopyresampled($dst, $src, 0, 0, 0, 0, $tn_width, $tn_height, $width, $height);
if(isset($this->query[1]) AND $this->query[1]='preview') {
$copy = ImageCreateFromPng('image/copy.png');
imagealphablending($dst, true); //three (from replace watermark true alfa chanel save [!] only from watermark replace over resize source image)
imagecopyresampled($dst, $copy, $tn_width - 125, $tn_height - 35, 0, 0, 125, 35, 125, 35);
ImageDestroy($copy);
}
header("Content-type: image/png");
ImagePng($dst, null);
ImageDestroy($src);
ImageDestroy($dst);
}