duanpanhuo0618 2013-01-21 11:48
浏览 44

GD Library无法正常工作

The generate.php is working, however if I try to retrieve the image on my index.php using <img src="generate.php"/> I get a blank screen.

generate.php

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

    if(isset($_GET['email'])){
        $email = $_GET['email'];
    }else{
        $email = 'No email specified';
    }
    $email_length = strlen($email);

    $font_size = 4;

    $image_height = ImageFontHeight($font_size);
    $image_width = ImageFontWidth($font_size) * $email_length;

    $image = imagecreate($image_width, $image_height);

    imagecolorallocate($image, 255, 255, 255);
    $font_color = imagecolorallocate($image, 0, 0, 0);

    imagestring($image, $font_size, 0, 0, $email, $font_color);
    imagepng($image);
?>

index.php

Name:<br>
Dave
<br><br>
Email: <br>
<img src="generate.php"/>
  • 写回答

1条回答 默认 最新

  • douyun1950 2013-01-21 11:53
    关注

    This may be an encoding error messing up the image header.

    Ensure your generate.php is saved as UTF-8 without BOM, or ASCII.

    评论

报告相同问题?

悬赏问题

  • ¥50 三种调度算法报错 有实例
  • ¥15 关于#python#的问题,请各位专家解答!
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败
  • ¥20 java在应用程序里获取不到扬声器设备