Color Palette PHP
A powerful PHP library for extracting color palettes from images and generating color themes. This package supports multiple image processing backends (GD and Imagick) and provides a rich set of color manipulation features.
🎨 Key Features
Advanced Color Extraction
- Multiple Backends: Support for both GD and Imagick image processing
- Smart Sampling: Efficient color sampling algorithms for accurate palette generation
- Format Support: Compatible with JPEG, PNG, GIF, and other common image formats
- Customizable: Adjustable color count and sampling parameters
Comprehensive Color Space Support
- RGB: Standard RGB color manipulation
- HSL/HSV: Intuitive color adjustments with Hue, Saturation, and Lightness/Value
- CMYK: Print-ready color space conversion
- LAB: Perceptually uniform color space for accurate color matching
- Hex: Web-friendly hexadecimal color codes
Powerful Color Manipulation
- Color Adjustment: Lighten, darken, saturate, and desaturate colors
- Color Mixing: Blend colors and create gradients
- Color Rotation: Rotate hues and create color variations
- Brightness Control: Fine-tune color brightness and contrast
Intelligent Theme Generation
- Automatic Palettes: Generate harmonious color schemes
- Accessibility: Built-in contrast ratio calculations
- Smart Defaults: Automatic text color optimization
- Theme Variations: Create light and dark theme variants
🚀 Quick Start
Installation
composer require farzai/color-palette
Basic Usage
use Farzai\ColorPalette\ImageFactory;
use Farzai\ColorPalette\ColorExtractorFactory;
use Farzai\ColorPalette\ColorPalette;
// Create an image instance
$imageFactory = new ImageFactory();
$image = $imageFactory->createFromPath('path/to/image.jpg');
// Extract colors
$extractorFactory = new ColorExtractorFactory();
$extractor = $extractorFactory->make('gd'); // or 'imagick'
$colors = $extractor->extract($image, 5); // Extract 5 dominant colors
// Create a palette and get color suggestions
$palette = new ColorPalette($colors);
$textColor = $palette->getSuggestedTextColor($colors[0]);
$surfaceColors = $palette->getSuggestedSurfaceColors();
📚 Documentation
Our comprehensive documentation covers everything you need:
🏁 Getting Started
Quick installation and basic setup guide to get you up and running.
🎯 Core Concepts
Deep dive into color spaces, manipulation, and best practices.
📖 API Reference
Complete API documentation with detailed examples and use cases.
💡 Examples
Real-world examples and code snippets for common scenarios.
🎮 Color Playground
Interactive demo to experiment with color manipulation features.
🛠 Requirements
- PHP 8.1 or higher
- GD extension or ImageMagick extension
- Composer for dependency management
🤝 Contributing
We welcome contributions! Please see our Contributing Guide for details.
📄 License
The Color Palette PHP library is open-sourced software licensed under the MIT license.