error “convert: invalid parameter”

August 10, 2009 by nuno costa 4 comments

phMagick :: error convert: invalid parameter

If you get this error on windows is because windows is finding the convert.exe (used to convert a file system to ntfs) instead of the ImageMagick convert.exe

Here are a few possible solutions

  • Use $phMagick->setImageMagickPath(‘C:/progra~1/imagemagick/bin’) or the path to where your ImageMagick binaries are
  • Change the %PATH% environment variable so the path to ImageMagick comes in first place
  • Edit phMagick source and change $imageMagickPath=” to $imageMagickPath=’C:/progra~1/imagemagick/bin’; (around line 38)

Make sure you end your path with / and avoid spaces in the path, use the short file name syntax

4 comments so far Add Your Comment

  1. by chinmoy on December 17 2009 at 08:36

    hi,
    i use wamp and it is installed in d drive.i have copied the line $phMagick->setImageMagickPath(’C:/progra~1/imagemagick/bin’) in my index.php file but i am getting this error -
    phMagick: Error executing “convert -fill “#000″ -pointsize 12 label:”phMagick rules!!!!!” “text1.png”"
    return code: 4
    command output :”Invalid Parameter – “#000″”

  2. by nuno costa on January 20 2010 at 21:27

    @chinmoy

    is imagemagick installed on that path?

  3. by Pal on January 5 2012 at 22:10

    platform: Windows Server 2008 64bit
    PHP5: 64bit
    ImageMagick Version: ImageMagick 6.7.4-2 2011-12-22 Q16

    I was having some of the same problems getting the basic script to work, ie. the examples which Nuno so kindly provided. thanks Nuno for all your work.

    Bottom line I was getting same errors..
    ======================================
    phMagick: Error executing “convert -scale “2000x>” -quality 80 -strip “source.png” “resized.jpg”"
    return code: 4
    command output :”Invalid Parameter – “2000x>”"
    =====================================
    this is despite Image Magick being the first entry in my windows PATH… path=D:\ImageMagick;etc etc and also specifying the MAGICK_HOME=D:\ImageMagick AND with successful test of CONVERT from any command prompt. With all that set the phMagick stuff was still erroring out. ONLY after specifying the ImageMagick path in the phMagick command below in my example did my two test work. For demonstration I have included two working examples.

    Best regards everyone.

    working samples
    ===========================
    debug=true;
    $p->setImageMagickPath(“D:\ImageMagick”);
    $p->rotate(45);
    echo ”;
    echo ‘

    ', print_r($p->getLog()) , '

    ‘;

    $phMagick = new phMagick(‘source.png’, ‘resized.jpg’);
    $phMagick->debug=true;
    $phMagick->setImageMagickPath(“D:\ImageMagick”);
    $phMagick->resize(2000,0);
    echo ”;

    echo ‘

    ', print_r($phMagick->getLog()) , '

    ‘;

    ?>

  4. by Pal on January 5 2012 at 22:11

    sorry folks, i screwed up the previous post, here is complete PHP script content
    ==================

    include(“subs/phmagick.php”);

    $p = new phMagick(“source.png”,”destination.png”);
    $p->debug=true;
    $p->setImageMagickPath(“D:\ImageMagick”);
    $p->rotate(45);
    echo ”;
    echo ‘

    ', print_r($p->getLog()) , '

    ‘;

    $phMagick = new phMagick(‘source.png’, ‘resized.jpg’);
    $phMagick->debug=true;
    $phMagick->setImageMagickPath(“D:\ImageMagick”);
    $phMagick->resize(2000,0);
    echo ”;

    echo ‘

    ', print_r($phMagick->getLog()) , '

    ‘;

More from francodacosta.com

© francodacosta.com - All rights reserved