Installation
Prerequisites
Section titled “Prerequisites”Before installing the Imagick Image Processor library, ensure your system meets the following requirements:
- PHP: Version 8.1 or higher
- Imagick Extension: Version 3.7 or higher
Installing the Imagick Extension
Section titled “Installing the Imagick Extension”If you don’t have the Imagick extension installed, follow the instructions for your operating system:
sudo apt-get updatesudo apt-get install php-imagicksudo systemctl restart apache2 # or php-fpm# Using Homebrewbrew install imagemagickpecl install imagick
# Add to php.iniecho "extension=imagick.so" >> /usr/local/etc/php/php.ini- Download the appropriate DLL from PECL
- Place it in your PHP extensions directory
- Add
extension=php_imagick.dllto yourphp.ini - Restart your web server
Verify Installation
Section titled “Verify Installation”Check if the Imagick extension is installed and enabled:
php -m | grep imagickYou should see imagick in the output.
Installing via Composer
Section titled “Installing via Composer”The recommended way to install the Imagick Image Processor is through Composer.
Step 1: Install Composer
Section titled “Step 1: Install Composer”If you don’t have Composer installed, download and install it from getcomposer.org.
Step 2: Install the Package
Section titled “Step 2: Install the Package”Run the following command in your project directory:
composer require kenura/imagickThis will:
- Download the library and its dependencies
- Add it to your
composer.jsonfile - Update your
composer.lockfile - Generate the autoloader
Step 3: Include the Autoloader
Section titled “Step 3: Include the Autoloader”In your PHP files, include Composer’s autoloader:
<?php
require_once __DIR__ . '/vendor/autoload.php';
use Kenura\Imagick\ImageProcessor;
// Now you can use the ImageProcessor class$processor = new ImageProcessor();Manual Installation
Section titled “Manual Installation”If you prefer not to use Composer, you can manually download and include the library:
- Download the latest release from GitHub
- Extract the files to your project directory
- Include the
ImageProcessor.phpfile:
<?php
require_once __DIR__ . '/path/to/src/ImageProcessor.php';
use Kenura\Imagick\ImageProcessor;
$processor = new ImageProcessor();Verifying the Installation
Section titled “Verifying the Installation”Create a simple test script to verify everything is working:
<?php
require_once __DIR__ . '/vendor/autoload.php';
use Kenura\Imagick\ImageProcessor;
try { $processor = new ImageProcessor(); echo "✅ Imagick Image Processor is installed and ready to use!\n";} catch (Exception $e) { echo "❌ Error: " . $e->getMessage() . "\n";}Run the script:
php test.phpIf you see the success message, you’re all set! 🎉
Next Steps
Section titled “Next Steps”Now that you have the library installed, check out the Quick Start Guide to learn how to use it, or explore the Guides for specific use cases.