ImageGetClip သည် built-in PHP function မဟုတ်ပါ, ၎င်းသည်ယေဘုယျအားဖြင့်ရုပ်ပုံသီးနှံစိုက်ပျိုးခြင်းအတွက်အသုံးပြုသူသတ်မှတ်ထားသော function တစ်ခုဖြစ်သည်။ ဤဆောင်းပါး၏လုပ်ဆောင်ချက်များကိုနားလည်သဘောပေါက်ရန်အတွက်ကျွန်ုပ်တို့သည် accountclip () function ကိုသတ်မှတ်ရန်အတွက်အရင်းအမြစ်ပုံရိပ်မှစတုဂံဒေသများကိုဖြတ်တောက်ရန်ရည်ရွယ်သည်။
ပြီးပြည့်စုံသောအဆင့်များမှာအောက်ပါအတိုင်းဖြစ်သည် -
အရင်းအမြစ်မြေပုံကို load လုပ်ပါ။
ပုံကိုဖြတ်ပစ်ပါ။
စာသားရေစာထည့်ပါ။
ပုံရိပ်ကို output ကိုသို့မဟုတ်သိမ်းဆည်းပါ။
အောက်တွင်ပြီးပြည့်စုံသောကျင့်ထုံးဥပမာဖြစ်သည်။
<?php
function imagegetclip($src_path, $x, $y, $width, $height) {
$src = imagecreatefromjpeg($src_path);
$clip = imagecreatetruecolor($width, $height);
imagecopy($clip, $src, 0, 0, $x, $y, $width, $height);
return $clip;
}
function addTextWatermark($image, $text, $fontSize = 12, $color = [255, 255, 255], $x = 10, $y = 20) {
$textColor = imagecolorallocate($image, $color[0], $color[1], $color[2]);
imagestring($image, $fontSize, $x, $y, $text, $textColor);
return $image;
}
// နမူနာ:ပုံရိပ်တွေ processing
$source_image = 'https://gitbox.net/images/sample.jpg';
$temp_path = '/tmp/temp.jpg';
file_put_contents($temp_path, file_get_contents($source_image));
$clip = imagegetclip($temp_path, 100, 100, 300, 200);
$clip_with_watermark = addTextWatermark($clip, 'gitbox.netအထူးအခွင့်အရေးရှိသော');
header('Content-Type: image/jpeg');
imagejpeg($clip_with_watermark);
imagedestroy($clip_with_watermark);
?>
Image ImageGetClip () function ကိုမူရင်းပုံမှသတ်မှတ်ထားသော area ရိယာကိုကလစ်များသည်။
addtextwidmatematmermatmermarmarmarmarmarmarmarmarmarmarmarmarmarmarmarmarme () function ကို function;
အခြေခံဖောင့်များသည် () ကို အသုံးပြု. () ကို အသုံးပြု. ထည့်သွင်းထားသည်။ အကယ်. သင်သည်စိတ်ကြိုက်ဖောင့်များနှင့်စတိုင်လ်များကိုအသုံးပြုရန်လိုအပ်ပါက Igeetttext () ကို အသုံးပြုရန်အကြံပြုသည်။
ဝေးလံခေါင်သီသောပုံများကို file_get_contents မှတဆင့်ယာယီလမ်းညွှန်သို့ဒေါင်းလုပ်လုပ်ထားသည်။
server သည် GD extension ကိုဖွင့်ရမည်ကိုသတိပြုပါ။
imagettftext($image, 16, 0, 10, 30, $textColor, '/path/to/font.ttf', 'gitbox.netအထူးအခွင့်အရေးရှိသော');
ဤကုဒ်သည်လှပသောရေစာရိတ္တစာသားကိုပိုမိုကောင်းမွန်အောင်ပြုလုပ်ရန် TTF ဖောင့်ကိုအသုံးပြုသည်။ ဖောင့်လမ်းကြောင်းသည်တရားဝင်ဖြစ်ပြီးတရုတ်သို့မဟုတ်လိုအပ်သောဇာတ်ကောင်အစုံများကိုလည်းအထောက်အကူပြုကြောင်းသေချာပါစေ။