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 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥15 Python3.5 相关代码写作
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗