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 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大