What steps can be taken to troubleshoot the error "Class 'Imagick' not found" when using Imagick in PHP on Mac OS X?

To troubleshoot the error "Class 'Imagick' not found" when using Imagick in PHP on Mac OS X, you can check if the Imagick extension is properly installed and enabled in your PHP configuration. You can do this by checking the phpinfo() output or running php -m in the terminal. If Imagick is not installed, you can install it using Homebrew or PECL.

// Check if Imagick extension is installed and enabled
if (!extension_loaded('imagick')) {
    echo "Imagick extension not found. Please install Imagick extension.";
}

// Sample code to use Imagick
$image = new Imagick('image.jpg');
$image->resizeImage(200, 200, Imagick::FILTER_LANCZOS, 1);
$image->writeImage('resized_image.jpg');