How to use Imagick Extension in the Exeoutput for php 2021

I tried to copy the php_imagick.dll to the C:\Program Files (x86)\ExeOutput for PHP 2020\PHPRuntime73\ext and added to the ext folder through the extension interface but still the exe made with laravel application showing error imagick is required.

Make sure you are placing in correct folder. If you are using 73, then put extensions there. If using 73, put extensions there. Same goes for 74 :slight_smile:

1 Like

Another thing to keep in mind is “Make sure you use the 7.3 NTS (non-thread safe) version of the DLL”

Long ago had issues and was because I was using 7.3 TS (thread safe).

I tried the Non-thread version from this link
https://pecl.php.net/package/imagick/3.4.4/windows downloaded 7.3 Non-Thread Safe (NTS) x86
copied the php_imagick.dll to the C:\Program Files (x86)\ExeOutput for PHP 2021\PHPRuntime73\ext, and added from PHP extension “Copy in the Data \ext subfolder”.

Then added all the remaining .dll files(IM_MOd and CORE_RL ) in that folder to the exeoutput Data> ext folder. But after compiling phpinfo() not showing the imagick extension.

Make sure to copy all dependencies of php_imagick.dll into the same folder as the EXE or the Windows\System32 folder (not recommended this one though). Not in Data\ext because Windows loads DLLs from the same folder as the EXE.

2 Likes

Sounds like you have done everything correctly. Make sure you have compiled the DLL into project (Making php imagick extension work - SOLVED - #2 by gdgsupport)

The only other suggestion I have is to create a simple test project not using laravel. What I mean is a simple PHP project using imagick. This way you make it easier to troubleshoot.

Some simple PHP examples:

// Create an Imagick object
$image = new Imagick();

// Create a new image
$image->newImage(650, 400, new ImagickPixel('green'));

// Set the image format
$image->setImageFormat('png');

header('Content-type: image/png');

// Display the output image
echo $image;
$imagick = new Imagick("/path/to/image.jpg");
$imagick->resizeImage(800, 600, Imagick::FILTER_LANCZOS, 1);
$imagick->writeImage("/path/to/resized_image.jpg");

If you are advanced PHP user, then this may seem redundant, but I have solved a many exeout issues troubleshooting like this.

Here is a script I threw together that might come in handy on the troubleshoot journey:

// Check if Imagick is installed
if (!extension_loaded('imagick')) {
    echo 'Imagick not installed';
} else {
    echo 'Imagick installed';
}

// Check Imagick version
try {
    $imagick = new Imagick();
    $version = $imagick->getVersion();
    echo 'Imagick version: ' . $version['versionString'];
} catch (Exception $e) {
    echo 'Error occurred: ',  $e->getMessage(), "\n";
}

// Check if a specific method is available
if (method_exists('Imagick', 'resizeImage')) {
    echo 'resizeImage method is available';
} else {
    echo 'resizeImage method is not available';
}

// Check if a specific format is supported
$formats = $imagick->queryFormats();
if (in_array('JPEG', $formats)) {
    echo 'JPEG format is supported';
} else {
    echo 'JPEG format is not supported';
}
2 Likes

Just got back in office and looked back at old project using imagick. Yes, all the dependencies are in the folder with compiled exe and not in Data folder.

2 Likes

Yes. That was the issue, I was pasting the dependencies to the Data folder instead of exe folder

2 Likes