यह लंबे समय तक है कि मैं अभी भी इस समस्या का उत्तर ढूंढ रहा हूं .. मेरे द्वारा प्राप्त सभी समाधान फ़ॉन्ट नाम को पकड़ने के आसपास हैं लेकिन मुझे पूरा यकीन है कि यह मेरा नहीं है मुसीबत।PHP - imagettftext काम नहीं कर रहा है और जीडी स्थापित
यह जी.डी. तरह लग रहा है स्थापित किया गया है
array(11) {
["GD Version"]=>
string(27) "bundled (**2.0.34 compatible**)"
["FreeType Support"]=>
bool(false)
["T1Lib Support"]=>
bool(false)
["GIF Read Support"]=>
bool(true)
["GIF Create Support"]=>
bool(true)
["JPEG Support"]=>
bool(true)
["PNG Support"]=>
bool(true)
["WBMP Support"]=>
bool(true)
["XPM Support"]=>
bool(true)
["XBM Support"]=>
bool(true)
["JIS-mapped Japanese Font Support"]=>
bool(false)
}
से ऊपर तुम मेरे जी.डी. समर्थन देख सकते हैं। मेरा PHP संस्करण 5.3 है और मैं लिनक्स पर चल रहा हूं।
मैंने विभिन्न वेबसाइटों से कुछ अलग कोड उदाहरणों की कोशिश की है और कोई भी काम नहीं करता है। ImageString मेरे लिए काम करता है, लेकिन मैं imagettftext काम करने के लिए प्राप्त करने की आवश्यकता ..
यह पिछले कोड रहा है अब की कोशिश की है है
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
// Set the content-type
header('Content-Type: image/png');
// Create the image
$im = imagecreatetruecolor(400, 100) or die("Can't create image!");
// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $white);
// The text to draw
$text = 'Testing';
// Replace path by your own font path
$font = 'arial.ttf';
// Add some shadow to the text
imagettftext($im, 20, 0, 11, 21, $grey, 'arial.ttf', $text);
// Add the text
imagettftext($im, 20, 0, 10, 20, $black, 'arial.ttf', $text);
// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
?>
परिणाम:http://www.7679679.com/app/test-ansi.php
आप हेडर सेट करते हैं ... बस imagepng से पहले, क्या ERRORMSG आप मिलता है पाने के लिए? – michi
क्या php आपको कोई त्रुटि/सूचना देता है? 'Imagettftext' फ़ंक्शन वापस क्या करता है? यह अंक की सरणी या त्रुटि पर गलत लौटा देना चाहिए। '$ text_result = imagettftext (...) आज़माएं; अगर ($ text_result === झूठा) {echo ("ERROR");} अन्यथा print_r ($ text_result); '। एक और बात, जब आप अपनी नई बनाई गई छवि भर रहे हों, तो आपने ऊंचाई पर एक पिक्सेल छोड़ा और चौड़ाई पर केवल 2 9 पिक्सेल चौड़ाई भर दी, क्या यह उद्देश्य पर है? – Buksy
आपने उस सरणी को कैसे मुद्रित किया ??? – Saswat