मैंने एक ऐसी स्क्रिप्ट बनाई है जो PHP का उपयोग कर मौजूदा छवि के शीर्ष पर वॉटरमार्क जोड़ती है। यह सब अच्छा काम करता है। मैं इसे ऊपरी बाएं, नीचे बाएं, ऊपर दाएं, नीचे दाएं और केंद्रित पर स्थित करने में सक्षम हूं। अगर मैं चाहता हूं कि वॉटरमार्क को दोहराना कैसे है, तो मैं यह समझने में सक्षम नहीं हूं।मैं जीडी और PHP के साथ वॉटरमार्क छवि कैसे दोहरा सकता हूं?
मैं इस छवि की तरह एक दोहराई वॉटरमार्क करना चाहते हैं:
कोड:
function imagecopymerge_alpha($dst_im, $src_im, $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h, $pct){
// creating a cut resource
$cut = imagecreatetruecolor($src_w, $src_h);
// copying relevant section from background to the cut resource
imagecopy($cut, $dst_im, 0, 0, $dst_x, $dst_y, $src_w, $src_h);
// copying relevant section from watermark to the cut resource
imagecopy($cut, $src_im, 0, 0, $src_x, $src_y, $src_w, $src_h);
// insert cut resource to destination image
imagecopymerge($dst_im, $cut, $dst_x, $dst_y, 0, 0, $src_w, $src_h, $pct);
}
$imagesource = $image['file_path'];
$watermarkPath = $settings['watermark'];
$filetype = substr($imagesource,strlen($imagesource)-4,4);
$filetype = strtolower($filetype);
$watermarkType = substr($watermarkPath,strlen($watermarkPath)-4,4);
$watermarkType = strtolower($watermarkType);
// Let's pretend that $watermark and $image are now GD resources.
$imagewidth = imagesx($image);
$imageheight = imagesy($image);
$watermarkwidth = imagesx($watermark);
$watermarkheight = imagesy($watermark);
switch ($settings['watermark_location'])
{
case "tl": //Top Left
$startwidth = 20;
$startheight = 20;
break;
case "bl": //Bottom Left
$startwidth = 20;
$startheight = (($imageheight - $watermarkheight) - 20);
break;
case "tr": //Top Right
$startwidth = (($imagewidth - $watermarkwidth) - 20);
$startheight = 20;
break;
case "br": //Bottom Right
$startwidth = (($imagewidth - $watermarkwidth) - 20);
$startheight = (($imageheight - $watermarkheight) - 20);
break;
case "middle": //Middle/center
$startwidth = (($imagewidth - $watermarkwidth)/2);
$startheight = (($imageheight - $watermarkheight)/2);
break;
case "repeat":
// not sure what to do here
break;
default:
$startwidth = (($imagewidth - $watermarkwidth)/2);
$startheight = (($imageheight - $watermarkheight)/2);
}
imagecopymerge_alpha($image, $watermark, $startwidth, $startheight, 0, 0, $watermarkwidth, $watermarkheight,$settings['watermark_opacity']);
imagejpeg($image,NULL,90);
imagedestroy($image);
imagedestroy($watermark);
अपना कोड पोस्ट करने के बारे में कैसे। बस एक अनुमान है, लेकिन यह मदद कर सकता है। –
हम पूरी तरह से उस कोड को देखने की ज़रूरत है जिसे आप पहले से उपयोग कर रहे हैं ताकि हम आपको वॉटरमार्क दोहराने के तरीके के बारे में सुझाव दे सकें। – Charles
ने एक पास्ता पोस्ट किया .. कोड का एक टन .. स्विच केस पर फोकस समायोजित करें – Ronnie