Can't add image files, but other files upload fine

Just changed servers and everything went without a hitch...except for this one thing: we can't add image files to an item. DOC, DOCX, PDF--no problem--but try to add a jpg, gif, tif, or png and we get this:

Omeka has encountered an error

ImageMagick is not properly configured: invalid directory given for the ImageMagick command!

#0 /home/mesmer2/public_html/omeka/application/libraries/Omeka/File/Derivative/Image.php(149): Omeka_File_Derivative_Image::_getPathToImageMagick()
#1 /home/mesmer2/public_html/omeka/application/libraries/Omeka/File/Derivative/Image.php(113): Omeka_File_Derivative_Image::createImage('/tmp/3d34c04368...', '800', 'fullsize')
#2 /home/mesmer2/public_html/omeka/application/libraries/Omeka/File/Derivative/Image.php(222): Omeka_File_Derivative_Image::createDerivativeImages('/tmp/3d34c04368...')
#3 /home/mesmer2/public_html/omeka/application/models/File.php(248): Omeka_File_Derivative_Image::createAll('/tmp/3d34c04368...', 'image/png')
#4 /home/mesmer2/public_html/omeka/application/models/File/ProcessUploadJob.php(24): File->createDerivatives()
#5 /home/mesmer2/public_html/omeka/application/libraries/Omeka/Job/Dispatcher/Adapter/Synchronous.php(25): File_ProcessUploadJob->perform()
#6 /home/mesmer2/public_html/omeka/application/libraries/Omeka/Job/Dispatcher/Default.php(95): Omeka_Job_Dispatcher_Adapter_Synchronous->send('{"className":"F...', Array)
#7 /home/mesmer2/public_html/omeka/application/models/File.php(70): Omeka_Job_Dispatcher_Default->send('File_ProcessUpl...', Array)
#8 /home/mesmer2/public_html/omeka/application/libraries/Omeka/Record.php(282): File->afterInsert()
#9 /home/mesmer2/public_html/omeka/application/libraries/Omeka/Record.php(561): Omeka_Record->runCallbacks(Array, Array)
#10 /home/mesmer2/public_html/omeka/application/libraries/Omeka/Record.php(581): Omeka_Record->save('afterInsert')
#11 /home/mesmer2/public_html/omeka/application/models/Item.php(303): Omeka_Record->forceSave()
#12 /home/mesmer2/public_html/omeka/application/models/ItemBuilder.php(213): Item->saveFiles()
#13 /home/mesmer2/public_html/omeka/application/libraries/globals.php(505): ItemBuilder->addFiles()
#14 /home/mesmer2/public_html/omeka/application/models/Item.php(286): insert_files_for_item()
#15 /home/mesmer2/public_html/omeka/application/models/Item.php(153): Item->_uploadFiles('Upload', 'file', Array)
#16 /home/mesmer2/public_html/omeka/application/libraries/Omeka/Record.php(282): Item->beforeSaveForm(Object(Item), 'Upload', 'file', Array)
#17 /home/mesmer2/public_html/omeka/application/libraries/Omeka/Record.php(803): Omeka_Record->runCallbacks()
#18 /home/mesmer2/public_html/omeka/application/libraries/Omeka/Controller/Action.php(482): Omeka_Record->saveForm(Object(ArrayObject))
#19 /home/mesmer2/public_html/omeka/application/controllers/ItemsController.php(99): Omeka_Controller_Action->editAction(Array, Array)
#20 /home/mesmer2/public_html/omeka/application/libraries/Zend/Controller/Action.php(516): ItemsController->editAction('beforeSaveForm', Object(ArrayObject))
#21 /home/mesmer2/public_html/omeka/application/libraries/Zend/Controller/Dispatcher/Standard.php(295): Zend_Controller_Action->dispatch(Array)
#22 /home/mesmer2/public_html/omeka/application/libraries/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch()
#23 /home/mesmer2/public_html/omeka/application/libraries/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch()
#24 /home/mesmer2/public_html/omeka/application/libraries/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run('editAction')
#25 /home/mesmer2/public_html/omeka/application/libraries/Omeka/Core.php(165): Zend_Application->run(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#26 /home/mesmer2/public_html/omeka/admin/index.php(45): Omeka_Core->run()
#27 {main}

Can anyone spot the problem?

Recent version of Imagemagick is installed, php 5.2.17 is running, and Apache 1.3.42 is chugging away.

The Imagemagick path is /usr/local/bin/ according to the host provider (lunarpages), though when I test this path I get a fail with this message:


Warning: realpath() [function.realpath]: open_basedir restriction in effect. File(/usr/local/bin) is not within the allowed path(s): ('.:/proc/uptime:/tmp:/home:/usr/local/lib/php:/usr/home:/usr/local/bin/') in /home/mesmer2/public_html/omeka/application/controllers/SettingsController.php on line 82

Thanks in advance for suggestions--I've been hacking away at this all day and can't figure it out.


Can you ask your host to disable or relax the open_basedir restriction?

That's restricting your server from accessing the ImageMagick path correctly, which is why you're getting that error.

I did ask and they said that I can do it myself by editing .htaccess in /public_html to include the line:

suPHP_ConfigPath /home/username/public_html

where "username" is my cpanel login name

and then editing the appropriate php.ini files to include a more relaxed open_basedir setting...with no specifics. As I've looked around online for more details, I'm seeing conflicting information about which php.ini files need this change, as well as what the change should actually be.

I've tried adding:

open_basedir = "/home/mesmer2:/usr/local/bin/"

to php.ini in /public_html and in /home/mesmer2/public_html/omeka/application/controllers/php.ini but this isn't doing the trick.

Plus, one site I looked at said that if you have php5 installed, no modification to .htaccess is necessary.

If you can confirm that I've got the right open_basedir command and tell me where this change needs to be inserted, I'd be extremely grateful. I'm so close to having Omeka up and running here--I'd hate to have to abandon it at this stage because of what seems like a fairly small problem.



I think, with that ConfigPath setting, the php.ini you want to edit should be in your public_html folder.

You may be able to simply comment out (with a semicolon at the front of the line) the open_basedir line entirely, which should disable that restriction.

Otherwise, you probably want to take the old value (which was '.:/proc/uptime:/tmp:/home:/usr/local/lib/php:/usr/home:/usr/local/bin/) and modify it. It looks like it already contained /usr/local/bin/, so I believe the problem may have just been the trailing slash on that path. Getting rid of that last slash might do the trick.

OMG, we're so close....

So your fundamental point made me realize that the path was being duplicated, so after trying the overt suggestions you made but that didn't work, I tried deleting both the open_basedir line from the php.ini file in /public_html altogether AS WELL AS the path in the Imagemagick path field in Omeka's admin setting page.

Basically, I thought: "let me see what happens when the system has no outside influence from me whatsoever."

The good news: I can now upload an image.

The bad news: no thumbnails are generated (and Omeka warns me of this on the files tab of the Add/Edit page.

But here's the interesting part. After uploading an image, I can then call up that record and there's an icon for a broken image. If I mouseover that icon, I get the link to download the full size version of the image--and the downloading works perfectly.

So all that's broken here is the generation of the thumbnails that Omeka then needs to display on the Item page.

Does this give you an idea about what I might try in order to fix this last little thing?

So close....

Thanks again.


Omeka needs you to give a path in that ImageMagick path field, otherwise, as you saw, it won't be able to (and won't even try to) generate thumbnails for uploaded images.

So, you need to put the path back in there in the Omeka interface. If that's still not working, it would mean you haven't really solved the underlying problem. Taking the path away in the Omeka settings just stops us from trying to make thumbnails at all.


I see what you're saying. So I started trying different combinations of paths in the Imagemagick field and no matter what I try (e.g., /usr/local/bin/ or /usr/local/bin or /usr/local/ or /usr/ or whatever) I get this error:


Warning: realpath() [function.realpath]: open_basedir restriction in effect. File(/usr) is not within the allowed path(s): ('.:/proc/uptime:/tmp:/home:/usr/local/lib/php:/usr/home:/usr/local/bin/') in /home/mesmer2/public_html/omeka/application/controllers/SettingsController.php on line 82

What's notable here is that the path in the error message is unchanging no matter what path I type into the admin/settings/imagemagick path.

In an earlier message you suggested:

"Otherwise, you probably want to take the old value (which was '.:/proc/uptime:/tmp:/home:/usr/local/lib/php:/usr/home:/usr/local/bin/) and modify it."

Where would I find that path to modify it?


So, you definitely haven't disabled the open_basedir, or changed it, since the paths (they're in parentheses in that warning) are the same. The path being checked looks like it is changing (it's /usr in this warning, while it was /usr/local/bin before).

By "modify it," I just meant that you could set the open_basedir setting in php.ini using that old value as a base. Something as simple as .:/proc/uptime:/tmp:/home:/usr/local/lib/php:/usr/home:/usr/local/bin (just omitting the trailing slash) could be your solution, but that's only if the changes you make in php.ini are actually taking effect.

If you make changes to open_basedir and the warning persists with those same old paths (.:/proc/uptime...), then I think your best move is to confirm with your host where your php.ini needs to be.

Your reply did the trick. Thank you.

I contacted the host and was told to revise the .htaccess code to read suPHP_ConfigPath /home/USER/public_html where I had uploaded the latest version of Zend, which Omeka calls for. I did this and the imagemagick test "Works!" and image uploading is golden.

Many thanks for your help, John. Very much appreciated!