简体   繁体   中英

imagick unable to read the file

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?

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 :-)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM