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 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵