how to show IM error info in php?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
linjuming
Posts: 122
Joined: 2011-01-25T00:09:50-07:00
Authentication code: 8675308

how to show IM error info in php?

Post by linjuming »

I use exec function to debug the im code. but it can not show the error info,so if the code is not correct ,i must run in cmd to see the error info,it is painful for me every time. Is there any method to show the error info in php?

Image
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: how to show IM error info in php?

Post by fmw42 »

read up about exec function arguments, one is a message array.

try this

<?php
exec("/usr/local/bin/convert -version",$out,$returnval);
print_r($out[0]);
?>

or

<?php
exec("/usr/local/bin/convert -list",$out,$returnval);
print_r($out);
?>

or use shell_exec as follows

<?php
$IM_version=shell_exec("/usr/local/bin/convert -version");
echo $IM_version
?>
linjuming
Posts: 122
Joined: 2011-01-25T00:09:50-07:00
Authentication code: 8675308

Re: how to show IM error info in php?

Post by linjuming »

Thanks! i see now.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: how to show IM error info in php?

Post by anthony »

How about stderr? :-)
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
linjuming
Posts: 122
Joined: 2011-01-25T00:09:50-07:00
Authentication code: 8675308

Re: how to show IM error info in php?

Post by linjuming »

Image

seems it doesn't work.
linjuming
Posts: 122
Joined: 2011-01-25T00:09:50-07:00
Authentication code: 8675308

Re: how to show IM error info in php?

Post by linjuming »

what is the meaning of "stderr" ?
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: how to show IM error info in php?

Post by Bonzo »

This is what I do and uses stderr:

Code: Select all

<?php
$array=array();
echo "<pre>";
exec("convert null.png good.png 2>&1", $array); 
echo "<br>".print_r($array)."<br>"; 
echo "</pre>";
?> 
linjuming
Posts: 122
Joined: 2011-01-25T00:09:50-07:00
Authentication code: 8675308

Re: how to show IM error info in php?

Post by linjuming »

thank you very much !
Post Reply