Configuring ImageMagick on MAMP for Windows


#1

Hello everyone,
I am bringing this question back as my problem is similar, “The ImageMagick directory path does not work.” but my Omeka is on my local server, I am using MAMP on Windows.

At the installation, the php module “fileinfo” was declared to be missing, so in C:\MAMP\bin\php\php7.0.9 and in C:\MAMP\conf\php7.0.9, I uncommented:
extension=php_fileinfo.dll

And it solved the problem. Now in the settings I get this message “The ImageMagick directory path does not work.” So I tried the following:

  • I installed IM 7 for Windows and made sure to tick the checkbox “Install legacy components (convert.exe etc)” during the installation since the Image Magick in MAMP does not contain convert.exe
  • I copied all the files of the ImageMagick folder and put them in C:\MAMP\bin\ImageMagick
  • in C:\MAMP\bin\php\php7.0.9 and in C:\MAMP\conf\php7.0.9, I uncommented:
    extension=php_imagick.dll
    extension=php_mime_magic.dll
  • I downloaded 4 files magic.mime, magic.mime.mgc, magic, magic.mgc of the GNU file package for windows (not the last version because it contains only 2 files, but the latest version that includes all 4 files, 4.23: http://downloads.sourceforge.net/gnuwin32/file-4.23-bin.zip?modtime=1213447945&big_mirror=1)
  • I extracted the files and place the 4 files in the folder extras/ of the version of PHP I use: C:\MAMP\bin\php\php7.0.9\extras
  • I added a new system environment variable called MAGIC refering to C:\MAMP\bin\php\php7.0.9\extras

But I still get the same message. I hope someone can have a look at this problem and post even resources or other forums I should check to better understand the problem, I am open to learning!


How to configure ImageMagick Directory Path
#2

What version of Omeka are you using?


#3

I am using Omeka 2.4.1 as I am using Curatescape (https://github.com/CPHDH/Curatescape) and this is the latest supported version.

When uploading my project on the host, I encounter absolutely no problem, so I can get around like this but that would be nice to be able to work locally as well.


#4

Omeka 2.5 makes some changes that should improve Windows path handling which might help.

The steps you’re taking combine at least 3 things that are basically separate, though:

  • One thing you’re changing settings and files for is file “magic,” the system PHP uses or used for determining what type a file is. This isn’t related to ImageMagick, despite the similar names. (These changes include the “php_mime_magic” extension, the 4 “magic” files you downloaded, and the “MAGIC” environment variable).
  • Another thing you’re doing is installing and pointing to the ImageMagick command-line tools (convert.exe). This is the traditional way to get thumbnailing working in Omeka. I wouldn’t be sure that you can just copy the files out from their installation directory to somewhere else and have them still work. This often isn’t the case on Windows.
  • The third thing is trying to set up the Imagick extension. This is the stuff dealing with “php_imagick.dll.” Usually you have to get that file separately and install it in php’s “ext” folder.

The simplest option should be: install ImageMagick from the installer (choose a simple folder name like c:\ImageMagick at install time just to make things easier), then use that path where it installed as the path you tell Omeka for the ImageMagick directory path. Once you start getting into copying things around and editing PHP’s configuration, you’re introducing a lot more variables, as well as making changes that don’t really affect the specific thing you’re trying to do.


#5

Thanks for the answer, you’re right I am probably doing too much magic(k) :dizzy:

  • At the moment I would rather stay with Omeka 2.4, as I am not sure I can use Curatescape with Omeka 2.5.

  • I tried the simple solution: install ImageMagick from the installer, that automatically installs it in C:\Program Files\ImageMagick-7.0.4-Q16, and then giving this path to Omeka but none of
    C:\Program Files\ImageMagick-7.0.4-Q16
    C:/Program Files/ImageMagick-7.0.4-Q16/
    …/Program Files/ImageMagick-7.0.4-Q16/ (I thought that the program could search from C:/MAMP)
    …/…/Program Files/ImageMagick-7.0.4-Q16/
    worked.

  • Another reason why I thought all these magic things where related, is that when inserting an item I get the following:

Exception: finfo::finfo(): Failed to load magic database at ‘(null)’. in C:\MAMP\htdocs\istanbul_international\application\libraries\Omeka\File\MimeType\Detect\Strategy\Fileinfo.php:21
Stack trace:

#0 C:\MAMP\htdocs\istanbul_international\application\libraries\Omeka\File\MimeType\Detect\Strategy\Fileinfo.php(21): finfo->finfo(1040)
#1 C:\MAMP\htdocs\istanbul_international\application\libraries\Omeka\File\MimeType\Detect.php(101): Omeka_File_MimeType_Detect_Strategy_Fileinfo->detect('C:\\Users\\oui16\\...')
#2 C:\MAMP\htdocs\istanbul_international\application\libraries\Omeka\Validate\File\MimeType.php(70): Omeka_File_MimeType_Detect->detect()
#3 C:\MAMP\htdocs\istanbul_international\application\libraries\Zend\File\Transfer\Adapter\Abstract.php(673): Omeka_Validate_File_MimeType->isValid('C:\\Users\\oui16\\...', Array)
#4 C:\MAMP\htdocs\istanbul_international\application\libraries\Zend\File\Transfer\Adapter\Http.php(148): Zend_File_Transfer_Adapter_Abstract->isValid('file_0_')
#5 C:\MAMP\htdocs\istanbul_international\application\libraries\Zend\File\Transfer\Adapter\Http.php(159): Zend_File_Transfer_Adapter_Http->isValid('file_0_')
#6 C:\MAMP\htdocs\istanbul_international\application\libraries\Omeka\File\Ingest\Upload.php(92): Zend_File_Transfer_Adapter_Http->receive('file_0_')
#7 C:\MAMP\htdocs\istanbul_international\application\libraries\Omeka\File\Ingest\AbstractIngest.php(179): Omeka_File_Ingest_Upload->_transferFile(Array, 'background_litt...')
#8 C:\MAMP\htdocs\istanbul_international\application\models\Builder\Item.php(200): Omeka_File_Ingest_AbstractIngest->ingest('file')
#9 C:\MAMP\htdocs\istanbul_international\application\libraries\globals.php(567): Builder_Item->addFiles('Upload', 'file', Array)
#10 C:\MAMP\htdocs\istanbul_international\application\models\Item.php(320): insert_files_for_item(Object(Item), 'Upload', 'file', Array)
#11 C:\MAMP\htdocs\istanbul_international\application\models\Item.php(230): Item->_uploadFiles()
#12 C:\MAMP\htdocs\istanbul_international\application\libraries\Omeka\Record\AbstractRecord.php(277): Item->beforeSave(Array)
#13 C:\MAMP\htdocs\istanbul_international\application\libraries\Omeka\Record\AbstractRecord.php(531): Omeka_Record_AbstractRecord->runCallbacks('beforeSave', Array)
#14 C:\MAMP\htdocs\istanbul_international\application\libraries\Omeka\Controller\AbstractActionController.php(188): Omeka_Record_AbstractRecord->save(false)
#15 C:\MAMP\htdocs\istanbul_international\application\controllers\ItemsController.php(151): Omeka_Controller_AbstractActionController->addAction()
#16 C:\MAMP\htdocs\istanbul_international\application\libraries\Zend\Controller\Action.php(516): ItemsController->addAction()
#17 C:\MAMP\htdocs\istanbul_international\application\libraries\Zend\Controller\Dispatcher\Standard.php(308): Zend_Controller_Action->dispatch('addAction')
#18 C:\MAMP\htdocs\istanbul_international\application\libraries\Zend\Controller\Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#19 C:\MAMP\htdocs\istanbul_international\application\libraries\Zend\Application\Bootstrap\Bootstrap.php(105): Zend_Controller_Front->dispatch()
#20 C:\MAMP\htdocs\istanbul_international\application\libraries\Zend\Application.php(384): Zend_Application_Bootstrap_Bootstrap->run()
#21 C:\MAMP\htdocs\istanbul_international\application\libraries\Omeka\Application.php(79): Zend_Application->run()
#22 C:\MAMP\htdocs\istanbul_international\admin\index.php(28): Omeka_Application->run()
#23 {main}

But I do not get this error on the host where the ImageMagick path is correct. Working directly on the host is not a solution though because I have a limited allowed daily usage in CPU seconds.

Do you have an idea of what is going on and what I should search to fix? Thank you in advance


#6

Hello there,

A quick update of where I am with my installation problems, after your answer helped me tear apart the 3 things:
With both Omeka 2.4 and Omeka 2.5, I got the same two problems:

  • a “magic” problem when inserting an item:
    Exception: finfo::finfo(): Failed to load magic database at '(null)'. in C:\MAMP\htdocs\istanbul_international\application\libraries\Omeka\File\MimeType\Detect\Strategy\Fileinfo.php:21
  • an “ImageMagick” problem:
    The ImageMagick directory path does not work.
    I also understood “Imagick” is another strategy that can be given to Omeka to use ImageMagick directly from php.
    (And I cannot get Omeka S to work: 403 Forbidden in Omeka S but this is another topic)

You probably have a lot of work and my problem is not completely Omeka related so I can understand if you cannot answer but I am kind of stuck in my work now.
As you see the project more globally, maybe you have quick suggestions of forums or resources I should check for these configuration problems?

Good luck for everything!


#7

I went and poked around on Windows with 2.5. The “path does not work” is just a small problem (we don’t add the “.exe” on Windows so we test the wrong path). Regardless, with the path set to the right folder, it should work anyway.

Even so, it’s broken… We produce the correct command line, spaces and all, it runs correctly if run from the command line. However, when we try to run it using PHP’s proc_open function, it doesn’t work, complaining that the file syntax is wrong. The problem seems to have to do with how PHP executes commands on Windows and how it tries to work around Windows’ strange quoting rules. I have a workaround that seems to work but I’m not sure if it has other negative effects.

For you the best and simplest option is probably for the time being to just switch the strategy to not use ImageMagick. The GD strategy generally works most easily as the necessary library is usually preinstalled along with PHP. You’d make this change by adding the following line to application/config/config.ini:

fileDerivatives.strategy = "Omeka_File_Derivative_Strategy_GD"

#8

Thanks for the answer :slight_smile: I could finally make it work with GD!

For the records, the solution to the “magic” problem:
Exception: finfo::finfo(): Failed to load magic database at '(null)'.
was to remove the environment variable MAGIC I had created earlier, and to restart the computer.

When this was done, I followed you for the “ImageMagick” problem:
with the default strategy ImageMagick I could not get the thumbnails, but at least I could load the item ; with the strategy GD I could get both the item and its thumbnails, thanks!


#9

I ran into the missing “.exe” problem with XAMPP on Windows. To use ImageMagick on both our XAMPP development server and Linux production server, I opted to make a core change for the XAMPP installation. In file

\application\libraries\Omeka\File\Derivative\Strategy\ExternalImageMagick.php

I changed:

const IMAGEMAGICK_CONVERT_COMMAND = 'convert';

to

const IMAGEMAGICK_CONVERT_COMMAND = 'convert.exe';

ImageMagick Directory Path
How to install ImageMagick on WAMP?
#10

I just learned that newer versions of ImageMagick have replaced convert.exe with magick.exe. To get ImageMagick to work with XAMMP on Windows 10, I’m now setting:

const IMAGEMAGICK_CONVERT_COMMAND = 'magick.exe';