ခေတ်သစ် e-commerce ဝက်ဘ်ဆိုက်များတွင် virtual foriting မှန်၏ features များသည်လူကြိုက်များလာသည်။ သုံးစွဲသူများသည်ပိုမိုများပြားသောစျေး 0 ယ်ခြင်းအတွေ့အကြုံကိုသာမကပြောင်းလဲခြင်းနှုန်းကိုလည်းတိုးတက်စေသည်။ ဤဆောင်းပါးသည် PHP တွင် Impflip () function ကိုမည်သို့အသုံးပြုရမည်ကိုမိတ်ဆက်ပေးနိုင်သည်။
PHP သည် Implip () function ကို 5.5.0 ကတည်းကမိတ်ဆက်ပေးသည်။ ၎င်းကိုပုံများလှန်ရန်အသုံးပြုသည်။ Syntax သည်အောက်ပါအတိုင်းဖြစ်သည် -
bool imageflip(GdImage $image, int $mode)
$ mode parameter သည်နောက်သုံးကိန်းသုံးခုအနက်မှတစ်ခုဖြစ်နိုင်သည်။
img_flip_horizontal : အလျားလိုက် Flip (ဘယ်ဘက်နှင့်ဘယ်ဘက်နှင့်လက်ဝဲနှင့်မှန်မှန်မှန်)
img_flip_vertical : ဒေါင်လိုက်လှန်ဖူးထားခြင်း (မှန်မှန်လှန်ခြင်း)
img_flip_both : အလျားလိုက်နှင့်ဒေါင်လိုက်လှန်လှောင်ပြောင်ကိုတစ်ပြိုင်နက်တည်းလုပ်ဆောင်ပါ
virtual တော်လျောက်ကြေးမုံ၏မြင်ကွင်းတစ်ခုတွင်အသုံးအများဆုံးမှာအလျားလိုက်လှန်လှောင်ထားသည်။
အသုံးပြုသူသည်မိမိကိုယ်ကို frontal ဓာတ်ပုံကိုတင်သည်။
အသုံးပြုသူများသည်အဝတ်အစားတစ်ချောင်းကိုရွေးချယ်သည် (ပွင့်လင်းမြင်သာသောနောက်ခံနှင့်အတူ PNG);
အဝတ်အစားအလွှာကိုအသုံးပြုသူ၏ဓာတ်ပုံပေါ်သို့ overlay;
အသုံးပြုသူများကို "in-mirror" ၏အကျိုးသက်ရောက်မှုကိုကြည့်ရှုရန်ခလုတ်များကိုနှိပ်ရန် imageflip () ကိုသုံးပါ။
ပြုပြင်ထားသောပုံရိပ်သည်နောက်ဆုံးတွင်နောက်ဆုံးတွင်ဖြစ်သည်။
ဤတွင်ရိုးရှင်းသောအကောင်အထည်ဖော်မှုဥပမာတစ်ခုဖြစ်သည်။
<?php
// အသုံးပြုသူဓါတ်ပုံများကို load လုပ်ပါ
$userImage = imagecreatefromjpeg('uploads/user.jpg');
// အဝတ်ကိုဝန်တင်PNG(ပွင့်လင်းနောက်ခံနှင့်အတူ)
$clothesImage = imagecreatefrompng('assets/clothes/shirt1.png');
// အဝတ်အလွှာ၏အကျယ်နှင့်အမြင့်ကိုရယူပါ
$clothesWidth = imagesx($clothesImage);
$clothesHeight = imagesy($clothesImage);
// အသုံးပြုသူမြေပုံပေါ်တွင်အဝတ်များ၏အနေအထားကိုသတ်မှတ်ပါ(ဒီနေရာမှာအလယ်မှာနေရာချခံရဖို့ယူဆတယ်)
$destX = (imagesx($userImage) - $clothesWidth) / 2;
$destY = 200; // ထိပ်တန်းအကွာအဝေး 200px,လိုအပ်သလိုချိန်ညှိနိုင်ပါတယ်
// ပွင့်လင်းအပြောင်းအလဲနဲ့ခွင့်ပြုပါ
imagealphablending($userImage, true);
imagesavealpha($userImage, true);
// ပုံများပေါင်းစည်း
imagecopy($userImage, $clothesImage, $destX, $destY, 0, 0, $clothesWidth, $clothesHeight);
// အသုံးပြုသူသည်မှန် mode ကိုတောင်းဆိုလျှင်
if (isset($_GET['mirror']) && $_GET['mirror'] == '1') {
imageflip($userImage, IMG_FLIP_HORIZONTAL);
}
// browser မှ output ကိုပုံရိပ်
header('Content-Type: image/png');
imagepng($userImage);
imagedestroy($userImage);
imagedestroy($clothesImage);
?>
အောက်ဖော်ပြပါ PHP နှင့်ကိုက်ညီသောရှေ့မျက်နှာပြင်၏ရိုးရှင်းသောစာမျက်နှာ၏ရိုးရှင်းသောဗားရှင်းဖြစ်သည်။
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<title>Virtual fitting မှန်</title>
</head>
<body>
<h2>Virtual fitting မှန်</h2>
<img src="http://m66.net/tryon.php" id="preview" style="max-width: 100%;"><br><br>
<button onclick="mirror()">Mirror Switch</button>
<script>
let mirrored = false;
function mirror() {
mirrored = !mirrored;
let img = document.getElementById('preview');
img.src = 'http://m66.net/tryon.php?mirror=' + (mirrored ? '1' : '0') + '&t=' + new Date().getTime();
}
</script>
</body>
</html>
PHP ၏ imageflip () function ကိုရိုးရိုး Image synthesis synthesis function နှင့်ပေါင်းစပ်ထားသော function မှတဆင့်ကျွန်ုပ်တို့သည်အခြေခံ virtual fritting မှန်ကိုအလွယ်တကူအကောင်အထည်ဖော်နိုင်သည်။ ဒီဥပမာဟာအတော်လေးရိုးရှင်းပေမယ့်ပိုပြီးအဆင့်မြင့် virtual virtual-up system ကိုအကောင်အထည်ဖော်ရန်အတွက်အခြေခံအုတ်မြစ်ချခဲ့သည်။ ပုံများ, မျက်နှာများအသိအမှတ်ပြုမှု positioning sookinging, 3D မော်ဒယ်လ်နှင့်အခြားနည်းပညာများနှင့်အခြားနည်းပညာများနှင့်အခြားနည်းလမ်းများကိုထပ်မံဖြည့်စွက်နိုင်သည်။
ဒီဆောင်းပါးကမင်းကိုကူညီလိမ့်မယ်လို့မျှော်လင့်ပါတယ်, ဒါကြောင့်စမ်းကြည့်ပါ။