0

我在一个文件中有以下 php 代码:

$figloc = $_GET['figrl'];

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

和一个像这样的jquery脚本:

<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 是一个 div 元素。$figloc 值是图像在磁盘上的绝对地址,如 '/home/abc/def/ghi/jkl.tiff'。从适当的链接打开 php 文件时,会显示错误消息“imagick 无法打开文件 /home/abc/def/ghi/jkl.tiff”。绝对地址会导致问题吗?

另外,当我将特定的 tiff 文件复制到我的目录时,为了查看绝对地址是否有问题,imagick 着迷地读取了该文件,但未能创建 temp.jpg

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

谁能指出我做错了什么?

4

1 回答 1

0

好的,我发现了问题所在。这是一个非常愚蠢的。我正在写作,所以面临同样问题的其他人可能会受益。

代替

$image = new Imagick($figloc);

写:

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

因此, figloc 字符串中的单引号被删除。真的很傻:-)

于 2012-11-06T00:16:36.810 回答