Check If ImageMagick and Ghostscript are installed on the Server

Create a PHP file. Let’s say it is in the main directory, so I go with index.php and paste the below code.

Open the website and it will show you a text message if there is software suit installed or not.

<?php
// Function to check if a command exists on the server
function isCommandAvailable($command) {
    $whereIsCommand = (PHP_OS == 'WINNT') ? 'where' : 'which';
    $process = proc_open(
        "$whereIsCommand $command",
        [
            1 => ['pipe', 'w'], // stdout is a pipe that the child will write to
            2 => ['pipe', 'w'], // stderr is a pipe that the child will write to
        ],
        $pipes
    );
    if ($process !== false) {
        $stdout = stream_get_contents($pipes[1]);
        $stderr = stream_get_contents($pipes[2]);
        fclose($pipes[1]);
        fclose($pipes[2]);
        $returnCode = proc_close($process);
        return $returnCode === 0;
    }
    return false;
}

// Check if Ghostscript is installed
$ghostscriptInstalled = isCommandAvailable('gs');

// Check if ImageMagick is installed
$imagemagickInstalled = isCommandAvailable('convert');

// Output results
echo 'Ghostscript is ' . ($ghostscriptInstalled ? 'installed' : 'not installed') . ".<br>";
echo 'ImageMagick is ' . ($imagemagickInstalled ? 'installed' : 'not installed') . ".<br>";
?>

Just run the PHP file and it will show you if your server has ImageMagick and Ghostscript.

Imagemagik and Ghostscript check using php