How to switch from GD to ImageMagic as image engine?

Hi. I often use Kirby for photo intensive pages and on the project I’m working on now I also use srcset for responsive images. One single image can end up having 4-8 different sizes (thumbnail + large image for gallery). I use the thumb() function to resize the uploaded images to all the different sizes which put a lot off work on the server. And if the gallery have a lot of images (10-20) the script will exit before all the images have been created and the page break.

For what I understand, ImageMagic can make a better job for this then the default GD library. Also ImageMagis should be better on handle big images. If this is true, can some one please help me switch from GD to ImageMagic? Or should I change the way I handling the images for the galleries on the page?

You can switch that in config.php

c::set('thumbs.driver', 'im');

http://getkirby.com/docs/advanced/options

Nice, Thank you.
Just can’t get ImageMagic to work with my MAMP installation. I have installed ImageMagic and can run it from the Terminal, but it doesn’t work on the web page.

Have you been able to solve this? I just ran into the same problem when I wanted to test the new unlimited thumb creation on panel; ImageMagick installed and accessible via terminal, extension=imagick.so enabled in Mamp Pro config, but not thumbs and the ImageMagick class not available via php

No I haven’t. Still got problem to get ImageMagic work. Did the the extension=imagick.so too but it didn’t help. I use the free version of MAMP (3.0.7.2) and OS X Yosemite. Would like to find a solution. On the Mamp Pro homepage they say that ImageMagic comes pre installed with version 3 (http://www.mamp.info/en/mamp-pro/).

Yeah, I tested this with Mamp Pro for that exact reason, that the php module comes preinstalled and you only have to switch it on in php.ini, but I would think that the module would show up in phpinfo which it doesn’t though.

Feels like I tried all the trix from all the articles on the web, but still not working.
If I do <?php phpinfo(); ?> I get an imagick sections so it looks like ImageMagic module is loaded.
Do I need to make som more changes in the Kirby code @bastianallgeier?

Maybe the path to the convert bin is not set properly in PHP. You can try to fix this by directly linking to convert with:

// config.php

thumb::$defaults['bin'] = '/usr/local/bin/convert';

Make sure to set the path right here. Not sure where it is located in your case.

There you go! Now it works, and ImageMagic does a better job, the page does not break now.
The path for me was:

thumb::$defaults['bin'] = '/opt/local/bin/convert';

Thank you.

Yeah, thanks, @bastianallgeier, that’s exactly what was missing …

Hello! Thanks for the helpful MAMP tips – I followed your advice, but none of the path options worked, while /Applications/MAMP/Library/bin/convert did. I have the feeling this is somehow not the right way, but will leave this here for reference. (Using MAMP Pro 3)

2 Likes

It is. Since ImageMagic is included with MAMP but not in the base system of OS X, the path you wrote is correct. It simply depends on the setup. :slight_smile:

Ah okay, I recall struggling with installing the lib several times and getting it to work via Terminal but not in MAMP. I was pretty happy when they finally included it in MAMP as the MAMP/Brew hacks differed on every OSX version.

For those joining us in 2016 or later -

you now need to do use this syntax instead:

c::set(‘thumbs.bin’, ‘/usr/local/bin/convert’);

Can we put this in the docs page on Thumbs Configuration?

As seen here:

Also, if you make a testfile.php with the contents:
<?php phpinfo() ?>

It’ll tell you which version of php you’re running in MAMP. Then you can use that to find the correct directory your mamp php.in is in. Replace the contents of that testfile.php with print(class_exists('imagick')); to test that the image magick class is available.

1 Like

Thanks for the suggestion. I have added a note, should be live on the site soon.

1 Like

Hello @lukasbestle, please add there a hint, that “XAMPP on Windows” until now has only the GD driver!

Some issues here had been written, because their developers did not know this.

It’s not related to XAMPP, users could still install the ImageMagic CLI themselves (that it needs to be available is stated in the docs already). Thanks for the suggestion though.

But using XAMPP I think to get the correct driver is not easy, so nearly nobody will be able to do this, if she/he is a newbie…

Normaly XAMPP is a black box without the source code!

But newbies don’t change the default thumb driver, right? :slight_smile:

thumbs.bin can be set in config file too, right?

c::set('thumbs.bin', 'path/to/convert');

from my expierence one has to logout of authentification to refresh the code in a thumbs driver. why is that btw?