If we use MagickReadImage and somehow it cannot read the image file, it terminates the script! wow... it's a BIG problem, why does it not return FALSE value and more importantly not terminating our script?
The error is shown like below:
Fatal error: magickreadimage(): C API cannot read the file "filename.gif" (reason: Improper image header `filename.gif') [on C source line 392]
I hope there's a command that I missed here to let the script flow... please!
ps. I have searched this forum and find this thread, seems somebody got into the same problem too.
MagickReadImage ERROR!
Re: MagickReadImage ERROR!
Hello,
I have the same Problem with MagickReadImages. When it fails to read one image the hole script is terminated without having a chance to handle this error.
According to the manual MagickReadImages should return "false" if something went wrong.
I don't think this kind of behaviour is intended, is there some way to fix this issue?
Maybe the function could net return "false" instead throw a exception?
With kind regards,
squig
I have the same Problem with MagickReadImages. When it fails to read one image the hole script is terminated without having a chance to handle this error.
According to the manual MagickReadImages should return "false" if something went wrong.
I don't think this kind of behaviour is intended, is there some way to fix this issue?
Maybe the function could net return "false" instead throw a exception?
With kind regards,
squig
Re: MagickReadImage ERROR!
The path forward would be to post a URL to a set of images we can download and post a script that we can run and reliably reproduce the problem you are having. If we can reproduce a problem-- we can fix it.
Re: MagickReadImage ERROR!
Hello,
I've tried the following code:
It works without problems if both pics are there but ends in a "fatal error" if one or both pics aren't found.
Testing in a directory without pics should reproduce this error.
Thank you.
squig
I've tried the following code:
Code: Select all
<?php
$wand = NewMagickWand();
if(!MagickReadImages($wand, array("pic1.jpg", "pic2.jpg"))) {
echo "error reading images.";
}
// process pics here
MagickWriteImages($wand, "./test.jpg");
?>
Testing in a directory without pics should reproduce this error.
Thank you.
squig
Re: MagickReadImage ERROR!
The problem is simply about properly classifying an exception in MagickWand for PHP. The MagickWand author decided that not finding an image is a fatal error. It could be his intent or perhaps a misclassification of this particular exception. If we change the exception from MW_E_ERROR to MW_E_WARNING you get the results you want. We will study the issue carefully this weekend and make the classification change if it makes sense and update MagickWand for PHP 1.0.2.
Re: MagickReadImage ERROR!
Hello,
I would really appreciate to be able to clean up in error case and inform the user.
I'm looking forward to read your decision.
With kind regards,
squig
I would really appreciate to be able to clean up in error case and inform the user.
I'm looking forward to read your decision.
With kind regards,
squig
Re: MagickReadImage ERROR!
MagickWand For PHP 1.0.2 will be released tomorrow with a patch to only issue an exception and return 0 if MagickReadImages() fails to read an image. It will no longer generate a fatal error and exit the script.
Re: MagickReadImage ERROR!
Hello,
Sorry I cannot reply earlier.
I assume the patch will work also for MagickReadImage too (not MagickReadImages only)? If so, I would greatly thankful for your work in solving the problem.
Best Regards,
Sorry I cannot reply earlier.
I assume the patch will work also for MagickReadImage too (not MagickReadImages only)? If so, I would greatly thankful for your work in solving the problem.
Best Regards,
Re: MagickReadImage ERROR!
Hello,
I've tried both functions, MagickReadImage and MagickReadImages, they now return false if an image couldn't be opened.
Thank you for this improvement.
squig
I've tried both functions, MagickReadImage and MagickReadImages, they now return false if an image couldn't be opened.
Thank you for this improvement.
squig