Using ImageMagick without shell_exec()

Posted on 2004-11-01
Last Modified: 2012-06-21

I used the following with ImageMagic on an old server and it worked great.

      $im_size = getimagesize($im_path . $im_file);
      if ($im_size[0]>70 && $im_size[1]>55)      shell_exec('im convert '.$im_path . $im_file .' -resize 70x55 +profile "*" '.$im_path.'thumbs/'.$im_file);      
      else      shell_exec('im convert '.$im_path . $im_file .' +profile "*" '.$im_path.'thumbs/'.$im_file);      

My new hosting company claims to offer support for ImageMagick but they don't support shell_exec.

Is there a way to do the above without using shell_exec?"

Question by:hankknight
    LVL 48

    Accepted Solution

    You might try using a native extension for the ImageMagick library. It requires that those extension is compiled (not part of php) and brought to the server by that hosting company.

    If they are not willing to do that and there is no possibility to run shell_exec there is no way to use ImageMagick.

    I guess all other shell-exec funtion like popen, `command` are also disabled.
    LVL 49

    Assisted Solution

    Look at the gdlib functions at the php manual:
    imagecreate() etc.

    You can use<?php phpinfo(); ?> to check for compatibility your hosting claimes to offer.


    LVL 48

    Expert Comment

    Hm guess the gd-lib has no possebility to add a profile (ICM, IPTC-tags) like IM, but might be better than nothing

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone. Privacy Policy Terms of Use

    Featured Post

    Course: MongoDB Object-Document Mapper for NodeJS

    NodeJS (JavaScript on the server) is awesome, but some developers get confused about NoSQL when it comes to working in Node with MongoDB (NoSQL database). Do you need a better explanation of how to use Node.js with MongoDB? The most popular choice is the Mongoose library.

    SQL injection vulnerabilities have been described as one of the most serious threats for Web applications. Web applications that are vulnerable to SQL injection may allow an attacker to gain complete access to their underlying databases. Because…
    Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    877 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now