At first, I have an image (card). I want to fill data card from the database using GD PHP to add text and merge QR code, no problem with merge QR code image. put the problem in adding Arabic text.
`public function exportCards(){
header('Content-type: image/png; charset=utf8');
// Create Image From Existing File
$jpg_image = imagecreatefrompng(asset('/images/card.png'));
// Allocate A Color For The Text
$white = imagecolorallocate($jpg_image, 0, 0, 0);
// Set Path to Font File
putenv('GDFONTPATH=' . realpath('.') . '/assets/');
$font_path = 'arial';
// Set Text to Be Printed On Image
$text = "";
// Print Text On Image
$text = "سمير سالم";
imagettftext($jpg_image, 12, 0, 50, 196, $white, $font_path, $text);
imagettftext($jpg_image, 12, 0, 50, 235, $white, $font_path, '400653210');
imagettftext($jpg_image, 12, 0, 50, 273, $white, $font_path, '500');
imagettftext($jpg_image, 12, 0, 50, 310, $white, $font_path, 'Senaaa');
imagettftext($jpg_image, 12, 0, 50, 347, $white, $font_path, 'SEN');
$imageName = time();
QrCode::format('png')->backgroundColor(222, 222, 246)->generate('Make me into a QrCode!', $_SERVER['DOCUMENT_ROOT'].'/oxfam/images/qrcode/'.$imageName.'.png');
$src = imagecreatefrompng(asset('/images/qrcode/'.$imageName.'.png'));
$thumb = imagecreatetruecolor(100, 100);
imagecopyresized($thumb, $src, 0, 0, 0, 0, 320, 300, 100, 100);
imagecopymerge($jpg_image, $thumb, 510, 200, 0, 0, 100, 99, 75);
$image = imagecreatetruecolor(700, 450);
imagecopy($image, $jpg_image, 0 ,0, 0,0, 700, 450);
imagepng($image, $_SERVER['DOCUMENT_ROOT'].'/oxfam/images/cards/'.time().'.png');
// Send Image to Browser
imagepng($jpg_image);
// Clear Memory
imagedestroy($jpg_image);
}
result ( ر ي م س م ل ا س) on image