doukougua7873 2012-11-05 23:06
浏览 58
已采纳

想象力无法读取文件

I have following php code in a file:

$figloc = $_GET['figrl'];

try
{
$image = new Imagick($figloc);
$image->setImageFormat("jpg");
$image->setImageColorSpace(5);  
$image->writeImage("temp.jpg");
}
catch(Exception $e)
{
 echo $e->getMessage();
}

and a jquery script like this:

<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function() {
    figurelocation='temp.jpg';
    var fightmlstring='<img src=\"'+figurelocation+'\">';
    $('.figuredisplay').append(fightmlstring);
});

figuredisplay is a div element. $figloc value is the absolute address of the image on disk, like '/home/abc/def/ghi/jkl.tiff'. The php file, when opened from appropriate link, shows the error message "imagick unable to open file /home/abc/def/ghi/jkl.tiff". Can the absolute address cause a problem?

Also, when I copied a particular tiff file to my directory, to see if the absolute address was a problem, imagick possessedly read that file, but failed to create temp.jpg

unable to open image `/var/www/temp.jpg @ error/blob.c/OpenBlob/2489 

Can anyone point me what I am doing wrong?

  • 写回答

1条回答 默认 最新

  • dourui9570 2012-11-06 00:16
    关注

    Ok, I figured out the problem. This was a really silly one. I am writing so others facing the same problem may benefit.

    Instead of

    $image = new Imagick($figloc);
    

    write:

    $abc= substr ( $figloc , 1, strlen($figloc)-2);
    $image = new Imagick($figloc);
    

    So, the single quotes from the figloc string are removed. Really silly :-)

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

报告相同问题?

悬赏问题

  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划