Debugging phMagick
There are 2 ways to debug phMagick
- Activate the debug mode, and then phMagick will issue warnings when a command fails
- Output the execution log and you will get information on the command executed, it’s return code and any errors/output from the execution
If you are on Windows you might want to read this, ImageMagick and Windows both have a program named convert and that can cause problems
A simple debug example:
- Create a new folder
- Copy phMagick.php and the plugins folder to that folder
- Copy an image to that folder and name it source.jpg
- Create a file and name it index.php and put the following code
include 'phMagick.php'; $phMagick = new phMagick('source.jpg', 'resized.jpg'); $phMagick->debug=true; $phMagick->resize(200,0); echo '< img src="resized.jpg">'; echo '<pre>', print_r($phMagick->getLog()) , '</pre>';
- Point your browser to that folder and watch the output
If you can’t figure it out mail me the output, I’ll do my best to help
Hi,
I have windows environment and I can run the command on command line but the phMagick fails. The debug information is:
phMagick: Error executing “convert -scale “200x>” -quality 80 -strip “testi.jpg” “resized.jpg”"
return code: 1
command output :”convert: unable to open image `resized.jpg’: Permission denied @ blob.c/OpenBlob/2480.”
Array
(
[0] => Array
(
[cmd] => convert -scale “200x>” -quality 80 -strip “testi.jpg” “resized.jpg”
[return] => 1
[output] => Array
(
[0] => convert: unable to open image `resized.jpg’: Permission denied @ blob.c/OpenBlob/2480.
)
)
)
1
Hi Ari,
It seems pretty obvious why you can not resize the image
unable to open image `resized.jpg’: Permission denied
Your web server user does not have write permission on that file or folder
I don’t know if its a problem or not,
Array
(
[0] => Array
(
[cmd] => C:/progra~1/ImageMagick-6.5.6-Q16/convert -scale “200x>” -quality 80 -strip “upload_image_noword.jpg” “resized.jpg”
[return] => 0
[output] => Array
(
)
)
)
1
the image is there (within the same folder), but it didn’t resize. Any ideas?
Hello Khairil ,
something seems to be wrong, you are getting no errors (the return code is 0 ) but the image is not created.
have you tried to run the command from the command line ?
I tried to execute a command, but get this error.
Array
(
[0] => Array
(
[cmd] => convert -density 90 -pointsize 72 label:Hello density.gif
[return] => 4
[output] => Array
(
[0] => Invalid parameter – 90
)
)
)
Hello Jan,
please check this http://www.francodacosta.com/blog/phmagick/examples/error-convert-invalid-parameter
Please: help me. My error is:
Array
( [0] => Array
( [cmd] => convert -scale “200x>” -quality 80 -strip “source.jpg” “resized.jpg”
[return] => 4
[output] => Array
( [0] => Parametro non valido – “200x>” )
))
1
Hello Federico,
Please check this page, http://www.francodacosta.com/blog/phmagick/examples/error-convert-invalid-parameter
windows is using the convert.exe to convert a partition to ntfs instead of imagemagick convert.exe
Hi
I need some help please. Whenever I try generating thumbnails from PDF, I get the follow error with some file and others work fine.
–
Current allocation mode is local
Last OS error: 2
GNU Ghostscript 7.07: Unrecoverable error, exit code 1
convert: Postscript delegate failed `extract.pdf’: No such file or directory @ pdf.c/ReadPDFImage/611.
convert: missing an image filename `extract.png’ @ convert.c/ConvertImageCommand/2772.
–
Any explanation of why this would happen.
Thanks
I think you have a problem with your ghostscript installation
Excellent work, mr. Costa, I’ll buy you a beer later!
At the moment I’m struggling with a function you may include freely if you so wish, but it might be a bit specialist.
(It’s supposed to swap red and blue color channels in order to enable me to work on/upload false color IR photographs with my iPhone)
The function I’ve written is this:
function swapchannelsrb(){
$cmd = $this->getBinary(‘convert’);
$cmd .= ‘ ‘;
$cmd .= $this->getSource();
$cmd .= ‘ -separate’;
$cmd .= ‘ -swap 0,2′;
$cmd .= ‘ -combine ‘;
$cmd .= $this->getDestination();
$this->execute($cmd);
$this->setSource($this->getDestination());
$this->setHistory($this->getDestination());
return $this ;
}
And I’m calling it into play with this code:
debug=true;
$phMagick->swapchannelsrb();
echo ”;
// echo ‘
‘;
?>
The return code I’m receiving is 126.
The example I’m using from imagemagick.org suggests this command:
convert rose: -separate -swap 0,2 -combine rose_rb_swap.gif
I’m submitting this command:
convert image.jpg -separate -swap 0,2 -combine swapped.jpg
Thanks!
Feel free to disregard my last comment, as I was confused about the installation at the time. Everything works smoothly now, it’s time for me to cough up that beer..
I’m glad everything is working fine!
Array
(
[0] => Array
(
[cmd] => convert -scale “200x>” -quality 80 -strip “test.png” “testDONE.jpg”
[return] => 127
[output] => Array
(
)
)
)
hm, what can I do?
If you are using windows, 127 means command not found