Why can't ImageMagick be run from a script?

  • updated
  • Answered

I am on a shared server, and would like to use ImageMagick to convert an SVG file to a jpeg image, but I have found that I can't run ImageMagick from within a PHP script. According to this page, it can only be run from the command line, or, on a shared server by using exec() or a cron job:


https://www.inmotionhosting.com/support/website/general-server-setup/is-imagemagick-installed-on-the-servers


1) Why aren't the APIs installed?


2) Is it possible to install them? Or is using exec() or a cron job really my only option?

Arn
Hello Jdgrimes,

The API's for Imagemagick ARE installed- as per the article you listed, Imagemagick is MOGRIFY and CONVERT. That article gives you the commands that you need to use. I had a systems person check and it definitely supports the conversion of SVG files. He asked that I warn you however that using the CONVERT command on the server can consume high resources depending on the number of images that you are converting. He suggested that you convert your images locally and then put them on the server to avoid possible issues. Running this for a large number of images on a shared server is not recommended.

If you have any further questions, please contact technical support or leave a comment at the bottom of the page.

Regards,

Arnel C.