[英]imagick unable to read the file
I have following php code in a file: 我在文件中有以下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();
}
and a jquery script like this: 和这样的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 is a div element. Figuredisplay是一个div元素。 $figloc value is the absolute address of the image on disk, like '/home/abc/def/ghi/jkl.tiff'.
$ figloc值是磁盘上映像的绝对地址,例如“ /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".
从适当的链接打开该php文件时,显示错误消息“ imagick无法打开文件/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 另外,当我将特定的tiff文件复制到目录中时,要查看绝对地址是否有问题,imagick会着手读取该文件,但无法创建temp.jpg。
unable to open image `/var/www/temp.jpg @ error/blob.c/OpenBlob/2489
Can anyone point me what I am doing wrong? 谁能指出我做错了什么?
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. 因此,figloc字符串中的单引号被删除。 Really silly :-)
真傻:-)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.