dongzj2015 2015-07-14 11:00
浏览 87

PHP图像显示错误

<?php
     $im = imagecreatetruecolor(120, 20);
     $text_color = imagecolorallocate($im, 233, 14, 91);
     imagestring($im, 1, 5, 5,  'A Simple Text String', $text_color);

     header('Content-Type: image/jpeg');

     imagejpeg($im);

     imagedestroy($im);
?>

this code is displaying error-

The image"http://localhost/untitled.php" cannot be displayed because it contains errors.

I am actually trying to make an image editor using php and here I am just simply trying to create an image using php and upload it in on the server. my code is showing the error as stated above.

What is actually the problem I don't understand.

  • 写回答

1条回答 默认 最新

  • dsbm49845 2015-07-14 11:34
    关注
    <?php
    $my_img = imagecreate( 200, 80 );
    $background = imagecolorallocate( $my_img, 0, 0, 255 );
    $text_colour = imagecolorallocate( $my_img, 233, 14, 91 );
    $line_colour = imagecolorallocate( $my_img, 233, 14, 91  );
    imagestring( $my_img, 4, 30, 25, "A Simple Text String", $text_colour );
    imagesetthickness ( $my_img, 5 );
    imageline( $my_img, 30, 45, 165, 45, $line_colour );
    
    header( "Content-type: image/jpg" );
    imagepng( $my_img );
    //imagecolordeallocate( $line_color );
    imagecolordeallocate( $text_color );
    imagecolordeallocate( $background );
    imagedestroy( $my_img );
    ?>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端