Installation

Requirements

Before installing the Crop library, ensure your system meets these requirements:

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

1
php --version

Ensure you’re running PHP 8.3 or higher.

Check ImageMagick Extension

1
php -m | grep imagick

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

1
composer test

Running Static Analysis

1
composer phpstan

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