Issues with imagick on live server

Edit: Reverting to GD works, but IM does not.


Edit: I am using Kirby 3.5.3.1

I have set up my config like so:

/site/config/config.php

return [
  'thumbs' => [
    'driver'    => 'im',
    'quality'   => 75,
    'srcsets' => [
      'default' => [
        '800w' => ['width' => 800, 'quality' => 75],
        '1024w' => ['width' => 1024, 'quality' => 75],
        '1440w' => ['width' => 1200, 'quality' => 70],
        '2048w' => ['width' => 1600, 'quality' => 60]
      ]
    ]
  ]
];

On my local dev, everything is working fine and images are resized. On the remote server, the large original file is always returned.

Looking at phpinfo on the live server I see imagick 3.4.4 is properly installed. I’ve also tried setting the binary path manually. After each adjustment to the config, I’ve removed the /media folder, but what I’ve noticed is that on the live server, the .jobs files are created but no actual thumbnails are being output.

The permissions seem to be correct as the Media folder is regenerated each time, just no actual resized files are generated.

EDIT: I found this similar thread: No thumbnail generated - #14 by lrntmszrs

However, GD is installed and confirmed in my phpinfo However, removing the 'driver' => 'im', and reverting to GD does work. However, the quality is not as good as im which my client is very particular about.

The most simple config like so is still failling:

return [
  'thumbs' => [
     'driver'    => 'im',
     'quality'   => 40,
     'bin'         => '/usr/bin/convert'
  ]
];

Have you tried connecting to the server directly, and checking whether the ‘convert’ executable is actually installed and reachable at /usr/bin/convert? - some server admins install packages in different places.

To find out where convert is installed, If you can ssh into your server, enter this command on your terminal:

which convert

It should output the absolute path of the convert binary - if it’s installed.

To make sure that the convert command is able to run without any problems, you can also try this on the terminal:

convert --version

Last of all, are the images you’re trying to convert simple .jpg/.png/.gif, or are they in a different format? Some formats - like .svg files - require extra tools to be installed alongside imagemagick, which might be missing from the server.

2 Likes

Thanks for the response. I’ve indeed checked and set the following:

which convert => /usr/bin/convert

convert --version

Version: ImageMagick 6.9.10-23 Q16 x86_64 20190101 https://imagemagick.org
Copyright: © 1999-2019 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib djvu fftw fontconfig freetype jbig jng jpeg lcms lqr ltdl lzma openexr pangocairo png tiff webp wmf x xml zlib

The images I’m trying to convert are jpg files, but somewhat large, 4MB. From the commandline, a conversion of the same file works perfectly: convert example.jpg -resize 1600 -quality 70 test.jpg

I also don’t see any errors in my apache/php logs.

Could it be that exec() doesn’t work on the server? But that should then generate an error message…

@waffl TBH I’m stabbing at the dark here, but without having direct access to your server, this is what I’d suggest next:

  1. Make sure that the imagick extension is actually being loaded by PHP. Login via ssh and type the following in your terminal, to see the list of modules PHP is loading - ‘imagick’ should appear in the list:
php -m
  1. I’m not sure whether Kirby uses exec() in imagemagick operations, but if it does, then it’s worthwhile checking whether it’s enabled, as @pixelijn suggested. In order to enable it, you need to have superuser access to the server (you need to be able to login as ‘root’, or to use “sudo” on the terminal). You then need to edit the disable_functions setting in the php.ini file on the server - normally located at /etc/php/php.ini. To edit it with the ‘nano’ editor, you’d do:
sudo nano /etc/php/php.ini

Then, look for the line with disable_functions in it, and make sure exec is not in the list. Save the file and restart the server.

  1. Last of all, the issue could also be related to the version of imagemagick that the server has installed. The version you seem to have is quite old - a couple of years old - so if at all possible, your server admin should update it for you. This will make operations faster, and might enable some operations that could be giving you trouble - like this one…
2 Likes

It does.

1 Like

Thank you all for the help! I checked and indeed the live server had exec disabled. I’ve enabled it in the php config and imagemagick is now working properly :slight_smile:

Indeed odd it didn’t throw, I grepped through all the logs for exec imagick but no sign. Good to know though, perhaps the exec requirement could be mentioned here: thumbs | Kirby

Thank you all again.