-
Notifications
You must be signed in to change notification settings - Fork 2k
Bug: Imagick handler on Windows #9927
Description
PHP Version
8.3
CodeIgniter4 Version
4.7.0
CodeIgniter4 Installation Method
Composer (using codeigniter4/appstarter)
Which operating systems have you tested for this bug?
Windows
Which server did you use?
apache
Environment
development
Database
MySQL 8.0
What happened?
I tried using Imagick for image processing on Windows and I get a weird error which would seem like permission issues specifically when using Imagick.
I get this error:
CodeIgniter\Images\Exceptions\ImageException
Your server does not support the GD function required to process this type of image. unable to open image '../writable/uploads/20260203/1770170502_aee0543926180b140099.png': No such file or directory @ error/blob.c/OpenBlob/3596
SYSTEMPATH\Images\Handlers\ImageMagickHandler.php at line 77
70 // Check for valid image
71 if ($this->resource->getImageWidth() === 0 || $this->resource->getImageHeight() === 0) {
72 throw ImageException::forInvalidImageCreate($this->image()->getPathname());
73 }
74
75 $this->supportedFormatCheck();
76 } catch (ImagickException $e) {
77 throw ImageException::forInvalidImageCreate($e->getMessage());
78 }
79 }
80 }
81
82 /**
83 * Handles all the grunt work of resizing, etc.
84 *
Steps to Reproduce
- Upload an image and process it using the \Config\Services::image service.
- Get the error.
My code example is like this:
$foto = $this->request->getFile('front_image');
if($foto->isValid()) {
$extension = $foto->getExtension();
$original = $foto->store();
$dpre = 'uploads';
if(!file_exists($dpre) and !is_dir($dpre)) {
mkdir($dpre);
chmod($dpre, 0755);
}
$dyear = $dpre.'/'.date("Y");
if(!file_exists($dyear) and !is_dir($dyear)) {
mkdir($dyear);
chmod($dyear, 0755);
}
$dmonth = $danio.'/'.date("m");
if(!file_exists($dmonth) and !is_dir($dmonth)) {
mkdir($dmonth);
chmod($dmonth, 0755);
}
$d = $dmonth;
$sizes = array(
array(1600, 900, 'large'),
array(800, 450, 'medium'),
array(400, 225, 'small')
);
foreach($sizes as $size) {
$filename = $size[0].'x'.$size[1].'_'.$basename.'.'.$extension; // basename is defined previously
$img = \Config\Services::image()
->withFile('../writable/uploads/'.$original)
->resize($size[0], $size[1], true)
->reorient()
->save($d.'/'.$filename);
}
}
With GD this code works, as soon as I switch to Imagick it stops working.
Everything works fine up to the first iteration of ->withFile(...) which is when the error occurs.
If I go to the uploads directory, the specific folder has been created, the file is uploaded, but there are some permission issues, because if I try opening the file I get this:
Expected Output
I expect the image to be processed with imagick instead of GD.
Anything else?
As for imagick I have this in phpinfo():
If I run php -m | findstr imagick I get:
PS C:\> php -m | findstr imagick
imagick
If I run php -v I get:
PS C:\> php -v
PHP 8.3.30 (cli) (built: Jan 13 2026 22:50:40) (ZTS Visual C++ 2019 x64)
Copyright (c) The PHP Group
Zend Engine v4.3.30, Copyright (c) Zend Technologies
with Zend OPcache v8.3.30, Copyright (c), by Zend Technologies