I've installed and configured Image 5.X-1.0 on a drupal 5.1 site. I copied image.imagemagick.inc to the includes directory. When I attempt to select and save imagemagick as my toolkit I get the dreaded /user/bin/convert does not exist error. I've confirmed with my hosting service that /user/bin/convert is the correct path and I've looked at pretty much every issue posting that I can find relating to imagemagick but nothing seems to fix the problem. Keeping in mind that I know just enough about all this to be dangerous, I'd appreciate any suggestions/recommendations for troubleshooting.

Comments

drewish’s picture

there've been some changes to the imagemagick toolkit going into the 5.x-1.0 release. did you have this working before hand with an older version?

a couple of other data points that might help. do you know what OS your host is using? what version of php are you running?

dougpetch’s picture

No, I've yet to get imagemagick to work. My host is running php 4.4.4 on Linux.

drewish’s picture

Status: Active » Fixed

try /usr/bin/convert not /user/bin/convert, another path might be /usr/local/bin/convert

dougpetch’s picture

Status: Fixed » Active

Actually, that was a typo. I am using /usr/bin/convert and have confirmed with my host that it's the correct path. Sorry 'bout that....

drewish’s picture

Status: Active » Needs review
StatusFileSize
new4.86 KB

please try out the attached patch. it changes around the way the path is validated

dougpetch’s picture

I applied the patch locally, replaced the image.imagemagick.inc file on my server with the patched version and ran update.php. The following error message appeared as soon as I opened the Image Toolkit page under administer-->site configuration:

The specified ImageMagic path /usr/bin/convert/ does not exist.

This is a minor change, as I previously only received the error when I attempted to "save configuration."

drewish’s picture

does it display the path with a trailing slash?

drewish’s picture

StatusFileSize
new5.23 KB

this really shouldn't change much but it'll print the version info correctly now if you do get it working ;)

(i trying to keep my latest patches posted because i often delete the code to test other patches and forget to a backup)

dougpetch’s picture

I've run the latest path and as you predicted it did not change the problem. And no, the trailing slash does not display - both the path textbox and the error message refer to /usr/bin/convert

dougpetch’s picture

I actually ran the latest patch, not the latest path....

drewish’s picture

could you install the devel module and enable the php block? once you get that installed could you run the following code? it should set a message with information on the file:

var_dump(filetype('/usr/bin/convert'));
drewish’s picture

run this too while you're at it:

var_dump(stat('/usr/bin/convert'));
dougpetch’s picture

Running the first line returned the following error:

warning: filetype() [function.filetype]: open_basedir restriction in effect. File(/usr/bin/convert) is not within the allowed path(s): (/home/dougp/:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/dougp/public_html/drupal/modules/devel/devel.module(624) : eval()'d code on line 1.

Running the second line returned the following message:

Parse error: syntax error, unexpected $end in /home/dougp/public_html/drupal/modules/devel/devel.module(624) : eval()'d code on line 1

If you haven't guessed by now, I'm not a programmer (and I don't play one on tv and I didn't stay at a holiday inn express), so I don't know what these messages are telling me or what I need to do to correct the problems. Hopefully though it will tell you that there's something simple that I need to do/undo to fix my problem....

drewish’s picture

well, open_basedir restriction in effect. File(/usr/bin/convert) is not within the allowed path(s): says it all. you can't call image magick because they've got php's safe mode enabled. you'll need to talk to them about it.

drewish’s picture

Title: imagemagick convert issues » warn if safe_mode + open_basedir prevents access to imagemagick
Status: Needs review » Needs work

okay we should really add code to warn people if this prevents access to image magick

dougpetch’s picture

Waiting on a response from my hosting service. Will update upon receipt.

dougpetch’s picture

Confirmed that safe_mode is enabled and that I am permitted to disable through a local php.ini file. Only problem - I don't know the correct command to use in the php.ini file I will create, and searching for the answer has been more confusing than helpful. The only command in the .ini file will be to disable safe_mode - could you possibly provide the correct command to make that happen? thx.

drewish’s picture

you could do it via your .htacccess file:

php_admin_value open_basedir none

or in the php.ini file:
open_basedir = ""

dougpetch’s picture

Finally got imagemagick working by modifying php_admin_value in .htaccess. Thanks for your help - and your patience.

drewish’s picture

glad you got it working. could you do me one favor and let me know if the existing patch works for you?

drewish’s picture

Status: Needs work » Needs review
StatusFileSize
new5.8 KB

okay, here's a patch that provides a warning if php's open_basedir feature is in use and the convert binary cannot be found. would you mind giving it a test?

dougpetch’s picture

I don't mind checking the patches and such, but after reinstalling the devel module in the modules folder I received the following error:

Fatal error: Call to undefined function: drupal_add_js() in /home/dougp/public_html/drupal/modules/devel/devel.module on line 166

Keep in mind - I'm not a programmer or developer so I have no idea what caused the error or how to fix it. And, since I'm running a production site I'm removing the devel module (again) in order to keep managing my site. If there's a simple fix to the error that you can share I'll be happy to try again for you, though.

dougpetch’s picture

Sorry - disregard #22 - operator head-space and timing issue. In answer to #20, I'm assuming that the existing patch is working because I am now able to enable imagemagick and it's saving images properly (thumbnail/preview/original). Is that what you're asking? As for #21 - since I now have access to the convert binary what, if anything, will the new patch do for me (that will be helpful for you, that is)?

drewish’s picture

since you became my imagemagick guinea pig (wink), just confirm that it still works for you, if you wouldn't mind, perhaps comment out the open_basedir line from your .htaccess to test that it fails with a warning that open_basedir might be screwing things up... if you could check those to things i'd really appreciate it.

dougpetch’s picture

The good news is that,yes things are working as they should with the patch installed and access to the convert binary enabled. The bad news is that the php_admin_value was actually changed in the global httpd.conf file for the server (as opposed to my site's .htaccess file as I originally thought) so I won't be able to easily disable it to test the warning function of the newest patch. Sorry - being your guinea pig has been a good learning experience for me.

drewish’s picture

Status: Needs review » Fixed

it worked for me but it's nice to get independent verification. i've committed this to HEAD and DRUPAL-5.

Anonymous’s picture

Status: Fixed » Closed (fixed)
jamesbrown’s picture

Title: warn if safe_mode + open_basedir prevents access to imagemagick » warn if safe_mode + open_basedir prevents access to imagemagick

I have the same problem now.
Apache/2.2.17 (FreeBSD)
PHP 5.2.14 with Suhosin-Patch 0.9.7 (cli) (built: Oct 19 2010 11:55:04)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
drupal-6.19

safe-mode in my php.ini is off, open_basedir is commented, as I see in phpinfo :
php -i | grep basedir
open_basedir => no value => no value

After writing "php_admin_value open_basedir none" in .htaccess I have error № 500 in my browser with my site.
P.S. I have the next record in my local (not sistem) php.ini (/home/user/data/php-bin/php.ini):
session.save_path = "/home/bahrain/data/bin-tmp"
Commenting that record and making in that directory symbolic reference to the /usr/local/bin/convert (under FreeBSD I have that file in /usr/local/bin) don't bring me any success.