Hi

How i can resolve this problem :

warning: is_file() [function.is-file]: open_basedir restriction in effect. File(/usr/bin/convert) is not within the allowed path(s): (/home/httpd/irdrupal.com/httpdocs:/home/httpd/irdrupal.com/irdrupal.com:/home/irdrupal/:/tmp:/usr/share/pear:/var/lib/php/session/:/home/kloxo/httpd/script) in /home/irdrupal/irdrupal.com/sites/all/modules/imageapi/imageapi_imagemagick.module on line 162

Comments

alexh’s picture

Component: ImageAPI GD » ImageAPI Imagick

The module logic assumes that you cannot use ImageMagick if the open_basedir security restriction is enabled.
But this is not true. On my shared host, I can execute /usr/bin/convert although it is not on the allowed paths.
Therefore, I added the following check in front of the others in the function _imageapi_imagemagick_check_path in the file imageapi_imagemagick.module (line 162):

  // Try it out and return without errors on success 
  $handle = popen($path . " -version", 'r');
  $im_version = fread($handle, 2096);
  pclose($handle);
  if (strpos($im_version, 'ImageMagick') !== FALSE) {
    return $errors;
  }

You can try with this. If it does not work you can also try to copy convert one of the allowed paths.

P.S. I changed Component to Imagick, because it is not related to GD, but to ImageMagick.

khan2ims’s picture

Thanks! The above worked for me!

Imran Khan
Project Manager
New Earth Marketing

drewish’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

goatvirus’s picture

yep, had to do the same today, with a client hosted on HostGo (http://www.hostgo.com ) First time this issue has given me grief, with installs of imagecache on the servers of quite a number of different hosting companies.

any chance that this patch can be added to the module itself? :-)

cheers
Peter 'Fish' Fisera
Earth Angel Consulting

bryanhidalgo’s picture

Thanks, #1 worked for me

lance.gliser’s picture

Title: warning: is_file() [function.is-file]: open_basedir » PHP's open_basedir restriction causes failure when convert is available, but not openable.
Category: support » bug
Status: Closed (fixed) » Needs review

Love the solution alexh. Very reasonable, and absolutely correct. This patch should be reviewed for addition to the module. It's a bug fix, not so much a support request. Modifying the statuses slightly to be more accurate.

lance.gliser’s picture

I created a patch of the above could. Could I get someone to try it out, please?
The patch I posted on this number won't work, it's applied at the project level, rather than the module.

lance.gliser’s picture

Version: 6.x-1.6 » 6.x-1.9
Assigned: Unassigned » lance.gliser
FileSize
671 bytes

Rerolled the changes to affect from the module's directory correctly to version 1.9.

lance.gliser’s picture

Status: Needs review » Needs work

Resetting the que to test the patch.

lance.gliser’s picture

Status: Needs work » Needs review
FileSize
671 bytes

This one includes proper unix line endings and utf-8 encoding

lance.gliser’s picture

This solution has been accepted into the image module's imagemagick code about a week ago.

zareen’s picture

This is still broken in the latest update 6.x-1.10. I updated and broke all my sites and had to search two days again for the fix cause I couldn't remember where I found it. Pasting in the code from number 1 fixed it. This time I'm going to remember where to find this fix!!!

lance.gliser’s picture

Assigned: lance.gliser » Unassigned
Status: Needs review » Reviewed & tested by the community

This has been tested by multiple people. Let's get it added to the next version if possible.

iantresman’s picture

This worked for me. Here are some simpler instructions:

  1. In the imageapi directory, make a backup copy, and then open the file: imageapi_imagemagick.module
  2. Search for the following function and change the code from:
    function _imageapi_imagemagick_check_path($path) {
      $errors = array();
      if (!is_file($path)) {

    To:

    function _imageapi_imagemagick_check_path($path) {
      $errors = array();
    
    // Try it out and return without errors on success
    $handle = popen($path . " -version", 'r');
    $im_version = fread($handle, 2096);
    pclose($handle);
    if (strpos($im_version, 'ImageMagick') !== FALSE) {
    	return $errors;
    }
    
      if (!is_file($path)) {