簡體   English   中英

imagefttext()沒有工作有什么想法?

[英]imagefttext() no t working have any idea?

這是例外:

            $im = imagecreatetruecolor(300, 100);
            $red = imagecolorallocate($im, 0xFF, 0x00, 0x00);
            $black = imagecolorallocate($im, 0x00, 0x00, 0x00);

            // Make the background red
            imagefilledrectangle($im, 0, 0, 299, 99, $red);

            // Path to our ttf font file
            $font_file = 'Oswald-Regular.TTF';

            // Draw the text 'PHP Manual' using font size 13
            imagefttext($im, 13, 0, 105, 55, $black, $font_file, 'PHP Manual');

            // Output image to the browser
            header('Content-Type: image/png');

            imagepng($im);
            imagedestroy($im);

這是結果:就是這樣

PNGIHDR,d c pHYSs? ? +?/IDATx 1 0 }: [ v& !fB ?b& !fB ?b& !fB ?b& !fB ?b& !fB ?b& !fB ?b& !fB ?b& !fB ?b& !fB ?b& !fB ?b& !fB ?b& !fB ?b& !fB ?b& !fB ?b& !fB ?b& !fB ?b& !fB ?b& !fB ?b& !fB ?b& !fB ?b& !fB ?b& !fB ?b& !fB ?b& !fB ?b& ! ǶyXIEND B`

@Klevis Cipi - 這是我運行的代碼,它生成了圖像。 在你調用imagepng之前沒有任何輸出嗎?

<?php

    $sText='Stackoverflow';
    $fontsize=18;

    $oImg   = imagecreatetruecolor(300, 100);
    $oRed   = imagecolorallocate($oImg, 255, 0, 0);
    $oBlack = imagecolorallocate($oImg, 0, 0, 0);

    // Make the background red
    imagefilledrectangle($oImg, 0, 0, 300, 100, $oRed);

    // Path to our ttf font file
    $font_file = 'c:/wwwroot/inc/fonts/arial.ttf';

    imagefttext($oImg, $fontsize, 0, 50, 55, $oBlack, $font_file, $sText );

    // Output image to the browser
    header('Content-Type: image/png');
    imagepng($oImg);
    imagedestroy($oImg);

?>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM