【问题标题】:Get imagejpeg to display properly让imagejpeg正确显示
【发布时间】:2012-02-17 19:58:18
【问题描述】:

无论如何我可以使用它来显示图像而无需保存它?

imagejpeg( $thumb, NULL, 100 );

这只会在网页上产生奇怪的字符。

【问题讨论】:

    标签: php image jpeg


    【解决方案1】:

    您需要正确设置 Content-Type 标头才能使其正常工作:

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

    【讨论】:

      【解决方案2】:

      你需要为它设置标题

      header('Content-Type: image/jpeg');
      imagejpeg( $thumb, NULL, 100 );
      

      (假设你知道imagejpeg的所有参数)

      【讨论】:

        【解决方案3】:
        $thumb = imagecreatefromjpeg($url);
        header('Content-type: image/jpeg');
        imagejpeg($thumb);
        imagedestroy($thumb);
        

        以上应该可以。 如果你在框架中这样做,你应该禁用布局。

        【讨论】:

          猜你喜欢
          • 2013-05-18
          • 2015-02-14
          • 2022-12-07
          • 1970-01-01
          • 1970-01-01
          • 2013-10-29
          • 1970-01-01
          • 2010-11-11
          • 1970-01-01
          相关资源
          最近更新 更多