Installation
Requirements
Before installing the Crop library, ensure your system meets these requirements:
- PHP 8.3 or higher with strict typing support
- ImageMagick extension with sRGB colorspace (version 6.7.5-5 or higher)
- Composer for package management
Install via Composer
The recommended way to install Crop is via Composer:
1
| composer require drzippie/crop
|
Verify Installation
After installation, verify that the library is working correctly:
1
2
3
4
5
6
7
8
| <?php
require_once 'vendor/autoload.php';
use drzippie\crop\CropCenter;
// Test basic functionality
$crop = new CropCenter();
echo "β
Crop library installed successfully!\n";
|
System Requirements Check
Check PHP Version
Ensure youβre running PHP 8.3 or higher.
Check ImageMagick Extension
Or check programmatically:
1
2
3
4
5
6
7
8
9
10
11
| <?php
if (extension_loaded('imagick')) {
echo "β
ImageMagick extension is available\n";
// Check ImageMagick version
$imagick = new Imagick();
$version = $imagick->getVersion();
echo "ImageMagick version: " . $version['versionString'] . "\n";
} else {
echo "β ImageMagick extension is not available\n";
}
|
Development Installation
For development and testing:
1
2
3
| git clone https://github.com/drzippie/crop.git
cd crop
composer install
|
Running Tests
Running Static Analysis
Docker Setup
For containerized development:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| FROM php:8.3-cli
# Install ImageMagick
RUN apt-get update && apt-get install -y \
libmagickwand-dev \
&& pecl install imagick \
&& docker-php-ext-enable imagick
# Install Composer
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
# Copy application
COPY . /app
WORKDIR /app
# Install dependencies
RUN composer install --no-dev --optimize-autoloader
|
Troubleshooting
Common Issues
ImageMagick not found:
1
2
3
4
5
6
7
8
9
| # Ubuntu/Debian
sudo apt-get install php-imagick
# CentOS/RHEL
sudo yum install php-imagick
# macOS with Homebrew
brew install imagemagick
pecl install imagick
|
Memory issues with large images:
1
2
3
4
5
| // Increase memory limit
ini_set('memory_limit', '512M');
// Or in your php.ini
memory_limit = 512M
|
Permission issues:
1
2
| # Ensure proper permissions for image files
chmod 644 /path/to/images/*
|
Next Steps