使用 gd 制作混合图像

我试图用 php 和 gd 库制作一个表单。表单包含一个带有透明包装的 png 徽标。现在我有3个问题:

  1. 当我制作边框时,我想将徽标放在图像的顶角,它不再是透明的背景

  2. 我使用波斯字体并使用 imagettftext 函数。它显示字符,但在波斯语中,我们合并了单词,但显示字符是分开的

  3. 如何绘制圆角边框

这是我的代码:

$fontSize=4;
$width = imagefontwidth($font) * strlen($string)+10 ;
$height = imagefontheight($font) ;


$handle = ImageCreate (800, 400) or die ("Cannot Create image");
$logo = imagecreatefrompng( 'Logo.png' );

$bg_color = ImageColorAllocate ($handle, 255, 240, 250);
$txt_color = ImageColorAllocate ($handle, 0, 0, 0);

$title="فرم قرارداد";
$font = "IRANSans.ttf";
$title_size = 18;
imagettftext( $handle, $title_size, 0, 620, 100, $txt_color, $font, $title );

$black = imagecolorallocate($handle, 0, 0, 0);
imagerectangle($handle, 20, 20, 780, 380, $black);
imagecopy($handle, $logo, 10, 10, 0, 0, 161, 160);

  header('Content-Type: image/png');
    imagepng($handle);
罗·阿赫特伯格
  1. 看到这个答案:php GD create a transparent png image
  2. 如果您想利用您的语言的排版特征,则必须使用 OpenType (.otf) 字体。
  3. 您可能想看看 GD 的imagearc

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章