resize watermark image
Posted: Mon Oct 15, 2012 8:53 pm
Hello,
I have an uploading image with watermark script. I also want that to resize the images. I have resize script but with al my efforts to watermark and resize the images while uploading it or watermarks the images or resize the images, never watermark and resize the images. So I put the resize and watermark functions together in one function but I'm not get this to work. It keeps the thumbnails black and when I click on the thumbnail it only shows the watermark, and also that is black.
What can I do to make this work?
The resize and watermark function is;
I have an uploading image with watermark script. I also want that to resize the images. I have resize script but with al my efforts to watermark and resize the images while uploading it or watermarks the images or resize the images, never watermark and resize the images. So I put the resize and watermark functions together in one function but I'm not get this to work. It keeps the thumbnails black and when I click on the thumbnail it only shows the watermark, and also that is black.
What can I do to make this work?
The resize and watermark function is;
function watermark_image($target, $output, $w, $h, $ext, $wm_image) { list($w_orig, $h_orig) = getimagesize($target); $scale_ratio = $w_orig / $h_orig; if (($w / $h) > $scale_ratio) { $w = $h * $scale_ratio; } else { $h = $w / $scale_ratio; } $img = ""; $ext = strtolower($ext); if ($ext == "gif"){ $img = imagecreatefromgif($target); } else if($ext =="png"){ $img = imagecreatefrompng($target); } else { $img = imagecreatefromjpeg($target); } $tci = imagecreatetruecolor($w, $h); imagecopyresampled($tci, $img, 0, 0, 0, 0, $w, $h, $w_orig, $h_orig); if ($ext == "gif"){ imagegif($tci, $newcopy); } else if($ext =="png"){ imagepng($tci, $newcopy); } else { imagejpeg($tci, $newcopy, 84); } $info = getimagesize($wm_image); switch ($info['mime']){ case 'image/jpeg'; $main = imagecreatefromjpeg($wm_image); break; case 'image/png'; $main = imagecreatefrompng($wm_image); break; case 'image/gif'; $main = imagecreatefromgif($wm_image); break; default: return false; } imagealphablending($main, true); imagecopy($tci, $main, 5, 5, 0, 0, imagesx($overlay), imagesy($overlay)); imagepng($main, $output); }Thanks