dsyak22488 2018-04-02 21:49
浏览 42
已采纳

防止GIF字符显示在屏幕上

I have this nice bit of code that generates a gif on the fly, where I place text over an existing image:

<?
$pic_name = "test.gif";

$gif_image = imagecreatefromgif('background.gif');
$text_color = imagecolorallocate($gif_image, 0, 0, 0);
     $font_path = 'arial.ttf';
      $text = "E-Signed By:";
      imagettftext($gif_image, 6, 0, 72, 11, $text_color, $font_path, $text);

      imagegif($gif_image);
      imagegif($gif_image, $pic_name);
      imagedestroy($gif_image);

?>

When I am done creating the image, I redirect to the next page:

echo 

"<html>
<head>
<meta HTTP-EQUIV='REFRESH' content='0; url=https://emortgagecapital.com/mlo/agreement.php'>

</head>
</html>";

The glitch is, on the redirect, for only a moment, I see a very long string of the GIF special characters, that looks something like this:

GIF87aR�9Z�9c�Bc�Jk�Rs�Z{�k��s��{�����

There is a lot more, but you get the idea.

Now, if I leave this bit of code in, the special characters don't display, but it kills the further execution of the script, and simply displays the image on screen:

header('Content-type: image/gif');

I tried placing the redirect as the header, but then the image never rendered and did not save to the server - the main reason for the script.

How do I run this script, and redirect, so the special characters do not 'flash' on the screen?

  • 写回答

1条回答 默认 最新

  • doucong3048 2018-04-02 21:54
    关注

    imagegif — Output image to browser or file

    imagegif($gif_image);

    your writing to the screen for no reason, just remove the line

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 手机连接电脑热点显示无ip分配
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大