【发布时间】:2019-03-23 23:17:54
【问题描述】:
我正在尝试使用 PHP GD 将印地文文本添加到图像中,并且文本正在转换为正方形,我认为这正在发生,php gd 不支持印地文文本。
请告诉我如何解决这个问题,或者有没有其他方法可以将印地语文本添加到图像中。
这是我正在使用的代码:
//Set the Content Type
header('Content-type: image/jpeg');
// Create Image From Existing File
$jpg_image = imagecreatefromjpeg('temp/mango.jpg');
// Allocate A Color For The Text
$white = imagecolorallocate($jpg_image, 255, 255, 255);
$black = imagecolorallocate($jpg_image, 0,0,0);
$font = dirname(__FILE__) . '/font/opensans.ttf';
// Set Text to Be Printed On Image
// Print Text On Image
imagettftext($jpg_image, 25, 0, 75, 300, $white, $font, "आम फलो का राजा है। ");
// Send Image to Browser
imagejpeg($jpg_image);
// Clear Memory
imagedestroy($jpg_image);
我得到的结果:
【问题讨论】:
-
我有点困惑,为什么它被标记为“phpmyadmin”,因为它似乎与 phpMyAdmin 应用程序或一般数据库无关。我现在将删除标签。
标签: javascript php