dream5694 2015-08-14 10:22
浏览 57

Imagick:包括PNG导致显示奇怪的符号

I'm using the following code to display an image which is stored on my webspace:

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

$filePath                       =   JPATH_SITE.'/images/powered_by.png';
$image                          =   new Imagick("{$filePath}[0]"); // [0] means "first page"
$image->setImageFormat('png');
echo $image;            
exit;

This happens in a modal-view of my Joomla-Component. The result is the following:

Modal with symbols

What can I do to display the image I wanted to display?

  • 写回答

1条回答 默认 最新

  • dongxuan2015 2015-08-14 12:18
    关注

    I believe you have a combination of things going wrong.

    i. you have errors disabled, which is not showing the real problem.

    ii. you have some whitespace at the beginning or end of a file. This is causing the headers to be sent before the code reaches the header('Content-Type: image/png');.

    iii. Because the headers have already been sent (with the default text content type) the browser is interpreting the image data as text, and so rendering it as text.

    There's nothing wrong with the code you have posted. What you need to do is find out what is causing the png content type not being sent to the browser - which I strongly suspect is going to be done by turning on the display of errors.

    评论

报告相同问题?

悬赏问题

  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制