0

を変更しようとしました$font_sizeが、機能していないようです。何があっても変わらない。$font_size130 まで変更しても、同じままです。

<?php
    header('Content-type: image/png');

    $rand_num = rand(1000, 9999);

    $font_size = 130;

    $image_width = 110;
    $image_height = 20;

    $image = imagecreate($image_width, $image_height);
    imagecolorallocate($image, 255, 255, 255);
    $black_color = imagecolorallocate($image, 0, 0, 0);

    imagestring($image, $font_size, 0, 0, $rand_num, $black_color);

    for($x=0; $x <= 30; $x++){
        $x1 = rand(1, 100); 
        $y1 = rand(1, 100);
        $x2 = rand(1, 100);
        $y2 = rand(1, 100);

        imageline($image, $x1, $y1, $x2, $y2, $black_color);
    }

    imagepng($image);
?>
4

3 に答える 3

0

PHPマニュアルによると、フォントパラメータ

latin2 エンコーディングの組み込みフォントの場合は 1、2、3、4、5 (数字が大きいほど大きなフォントに対応します)、または imageloadfont() で登録された独自のフォント識別子のいずれかになります。

したがって、130 ではなく、1 2 3 4 5 を試す必要があります。

于 2013-01-23T06:25:03.107 に答える
0

関数を使用してフォントサイズを変更できimagettftextます。

imagettftext($image, $font_size, $angle, $x, $y, $text_color, '$font-family', $text);

  $image is the $imagecreate function
  $font_size is the size of font you want.
  $angle is the angle of the fonts tilted
  $x and $y are coordinates.
  $text_color is the imagecolorallocate function
  $font-family is the family of font you want to use
  $text is the text or random text to be displayed
于 2013-10-28T05:59:36.517 に答える