我一直在为会员系统制作一张自动生成的卡片。 由PHPGD图像系统制作的卡片。 这是代码:
<?php
include_once('php_includes/check_login_status_member.php');
if ($user_ok == false ){
exit();
}
$sql = "SELECT * FROM members WHERE id_member='$log_id' LIMIT 1";
$query = mysqli_query($db_conx, $sql);
while ($row = mysqli_fetch_array($query, MYSQLI_ASSOC)) {
$id_komunitas = $row['id_komunitas'];
$id_card = $row['id_card'];
$nama_lengkap = $row['nama_lengkap'];
$id_member = $row['id_member'];
$avatar = $row['avatar'];
$profile_pic = $avatar;
if($avatar == NULL){
$profile_pic = 'avatar-1-256.png';
}
}
if (isset($_GET['id'])){
$id = preg_replace('#[^0-9]#', '', $_GET['id']);
if (empty($id)) {
$id = $id_card;
}
}
else {
$id = $id_card;
}
$sqlcard = "SELECT * FROM card WHERE id_card='$id' LIMIT 1";
$querycard = mysqli_query($db_conx, $sqlcard);
while ($rowcard = mysqli_fetch_array($querycard, MYSQLI_ASSOC)) {
$background = $rowcard['image'];
// $background = "cardbranch/bg.png";
}
$nol = str_pad($id_member, 7, "0", STR_PAD_LEFT);
$detail = pathinfo($background);
$detail2 = pathinfo($avatar);
if ($detail['extension'] == 'png'){
$img = imagecreatefrompng('assets/img/card/background/'.$background.'');
} else if ($detail['extension'] == 'jpg' || $detail['extension'] == 'jpeg') {
$img = imagecreatefromjpeg('assets/img/card/background/'.$background.'');
}
// if ($detail['extension'] == 'png'){
// $img = imagecreatefrompng($background);
// } else if ($detail['extension'] == 'jpg' || $detail['extension'] == 'jpeg') {
// $img = imagecreatefromjpeg($background);
// }
if($avatar == NULL){
$eclipse = imagecreatefrompng('assets/img/'.$profile_pic.'');
$mask = imagecreatetruecolor(256, 256);
$black = imagecolorallocate($mask, 0, 0, 0);
$magenta = imagecolorallocate($mask, 255, 0, 255);
imagefill($mask, 0, 0, $magenta);
imagefilledellipse(
$mask,
(256 / 2),
(256 / 2),
256,
256,
$black
);
imagecolortransparent($mask, $black);
imagecolortransparent($eclipse, $magenta);
imagecopymerge($eclipse, $mask, 0, 0, 0, 0, 256, 256, 100);
imagedestroy($mask);
} else {
if ($detail2['extension'] == 'jpg' || $detail2['extension'] == 'jpeg'){
$eclipsex = imagecreatefromjpeg('assets/img/user/profilepicture/'.$profile_pic);
$eclipse = imagescale($eclipsex, 172, 172);
} else if ($detail2['extension'] == 'png') {
$eclipsex = imagecreatefrompng('assets/img/user/profilepicture/'.$profile_pic);
$eclipse = imagescale($eclipsex, 172, 172);
}
$mask = imagecreatetruecolor(172, 172);
$black = imagecolorallocate($mask, 0, 0, 0);
$magenta = imagecolorallocate($mask, 255, 0, 255);
imagefill($mask, 0, 0, $magenta);
imagefilledellipse(
$mask,
(168 / 2),
(168 / 2),
168,
168,
$black
);
imagecolortransparent($mask, $black);
imagecolortransparent($eclipse, $magenta);
imagecopymerge($eclipse, $mask, 0, 0, 0, 0, 172, 172, 100);
imagedestroy($mask);
}
// $barisputih = imagecreatefrompng('assets/img/card/placeholder/barisputih.png');
// $barisbiru = imagecreatefrompng('assets/img/card/placeholder/barisbiru.png');
$layernama = imagecreatefrompng('cardbranch/layernama2.png');
$layertipe = imagecreatefrompng('cardbranch/layertipe2.png');
$shapeatas = imagecreatefrompng('cardbranch/shapeatas.png');
$shapebawah = imagecreatefrompng('cardbranch/shapebawah.png');
$layernomor = imagecreatefrompng('cardbranch/layernomor.png');
// $rec = imagecreatefrompng('cardbranch/rec.png');
$bisnisabah = imagecreatefrompng('cardbranch/x.png');
$putih = imagecolorallocate( $img, 255, 255, 255 );
imagealphablending($img, true);
imagesavealpha($img, true);
imageantialias($eclipse, true);
imagecopymerge($img, $layernama, 162, 51, 0, 0, 762, 69, 50);
imagecopymerge($img, $layertipe, 122, 131, 0, 0, 728, 54, 50);
imagecopymerge($img, $shapeatas, 153, 51, 0, 0, 770, 5, 100);
imagecopymerge($img, $shapebawah, 126, 131, 0, 0, 724, 4, 100);
imagecopymerge($img, $layernomor, 0, 335, 0, 0, 1050, 90, 50);
imagecopymerge($img, $bisnisabah, 783, 463, 0, 0, 266, 142, 60);
// imagecopymerge($img, $rec, 0, 335, 0, 0, 1050, 90, 50);
imagecopymerge($img, $eclipse, 33, 36, 0, 0, 172, 172, 100);
imagettftext($img, 34, 0, 234, 105, $putih, 'assets/img/card/font/norwester.otf', $nama_lengkap);
imagettftext($img, 23, 0, 234, 172, $putih, 'assets/img/card/font/norwester.otf', "Personal Member");
imagettftext($img, 45, 0, 110, 403, $putih, 'assets/img/card/font/norwester.otf', "01.04.2010 - ".$nol);
header('Content-Type: image/jpeg');
imagepng( $img );
imagecolordeallocate( $color );
imagedestroy( $img );
&GT;
这就是图片在网页中的样子:webpagescreenshot
问题是,我想在图像上添加斜角和浮雕,并且还要在20px左右的边界半径上添加,当然我们可以用css做到这一点 但是当用户下载图像时,风格当然会消失。我一直在尝试寻找帆布选项,使斜面和浮雕看起来像photoshop斜面和浮雕一样逼真,这就是我想要实现的图像:this one made by photoshop
因此,当他们下载图像时,他们将获得带有边框半径和斜角的图像,那么有没有办法用phpgd或canvas做这个图像效果?,谢谢你的帮助。抱歉我的英语不好。