Description
PHP Version
7.4
CodeIgniter4 Version
4.2.1
CodeIgniter4 Installation Method
Composer (using codeigniter4/appstarter
)
Which operating systems have you tested for this bug?
Linux
Which server did you use?
cli-server (PHP built-in webserver)
Database
MariaDB v5.5
What happened?
I'm migrating an app from CodeIgniter 3 to 4, and when trying to use the new image library it throws an exception:
CodeIgniter\Images\Exceptions\ImageException
The framework needs the following extension(s) installed and loaded: IMAGICK.
I have never installed the imagick extension with ci3, and according to the documentation it should not be required in ci4 either:
The ImageMagick handler does NOT require the imagick extension to be loaded on the server. As long as your script can access the library and can run exec() on the server, it should work.
Steps to Reproduce
Having just the command line imagemagick tools installed without the imagick extension.
.env
:
images.defaultHandler = 'imagick'
images.libraryPath = '/usr/bin/convert'
class Images extends BaseController {
private BaseHandler $image;
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) {
// Do Not Edit This Line
parent::initController($request, $response, $logger);
$this->image = Services::image(); // Exception thrown here
}
...
Expected Output
Would expect the library to load without the imagick extension installed.
Anything else?
Looking at the description in the code, it seems to agree with the documentation in that the extension is not required:
CodeIgniter4/system/Images/Handlers/ImageMagickHandler.php
Lines 22 to 24 in cee5528
However, the actual code looks for the extension and if it's not there it throws an exception in the constructor:
CodeIgniter4/system/Images/Handlers/ImageMagickHandler.php
Lines 46 to 54 in cee5528
If I comment out throw ImageException::forMissingExtension('IMAGICK');
then the library allows me to resize an image, so the documentation seems to be correct in that the extension is not required.
I have not finished migration yet, so there could be some cases that do not work though.