Debugging phMagick

August 10, 2009 by nuno costa 10 comments

 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

10 comments so far Add Your Comment

  1. by Ari on September 10 2009 at 10:14

    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

  2. by nuno costa on September 10 2009 at 13:27

    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

  3. by Khairil Harith on October 11 2009 at 20:14

    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?

  4. by nuno costa on October 12 2009 at 16:21

    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 ?

  5. by Jan-Berend on October 19 2009 at 12:02

    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
    )

    )

    )

  6. by nuno costa on October 23 2009 at 17:36
  7. by Federico on November 23 2009 at 12:45

    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

  8. by nuno costa on November 24 2009 at 12:11

    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

  9. by Koki on March 3 2010 at 14:52

    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

  10. by nuno costa on March 9 2010 at 21:32

    I think you have a problem with your ghostscript installation

More from francodacosta.com

© francodacosta.com - All rights reserved