chore: cleanup project structure and update readme for beta release

This commit is contained in:
2025-12-23 04:59:21 +07:00
parent 1640ced748
commit 10a00bac0e
122 changed files with 8320 additions and 661 deletions

View File

@@ -0,0 +1,253 @@
<?php
/*
|--------------------------------------------------------------------------
| HD Avatar Configuration
|--------------------------------------------------------------------------
| Configuration for high-definition avatar generation with enhanced
| performance through image export and storage optimization.
|
*/
return [
/*
|--------------------------------------------------------------------------
| HD Image Settings
|--------------------------------------------------------------------------
| Configuration for high-definition avatar generation
|
*/
'hd' => [
// Enable HD mode - when true, uses higher resolution settings
'enabled' => env('AVATAR_HD_ENABLED', true),
// HD dimensions (default: 512x512, supports up to 2048x2048)
'width' => env('AVATAR_HD_WIDTH', 512),
'height' => env('AVATAR_HD_HEIGHT', 512),
// HD font size (scales with dimensions)
'fontSize' => env('AVATAR_HD_FONT_SIZE', 192),
// Export quality settings
'quality' => [
'png' => env('AVATAR_HD_PNG_QUALITY', 95),
'jpg' => env('AVATAR_HD_JPG_QUALITY', 90),
'webp' => env('AVATAR_HD_WEBP_QUALITY', 85),
],
// Anti-aliasing for smoother edges
'antialiasing' => env('AVATAR_HD_ANTIALIASING', true),
// DPI for high-quality rendering
'dpi' => env('AVATAR_HD_DPI', 300),
],
/*
|--------------------------------------------------------------------------
| Export and Storage Settings
|--------------------------------------------------------------------------
| Configuration for image export and storage optimization
|
*/
'export' => [
// Default export format
'format' => env('AVATAR_EXPORT_FORMAT', 'png'), // png, jpg, webp
// Export path (relative to storage/app)
'path' => env('AVATAR_EXPORT_PATH', 'avatars'),
// Filename pattern: {name}, {initials}, {hash}, {timestamp}
'filename_pattern' => env('AVATAR_EXPORT_FILENAME', '{hash}_{timestamp}.{format}'),
// Enable multiple format export
'multiple_formats' => env('AVATAR_EXPORT_MULTIPLE', false),
// Progressive JPEG for better loading
'progressive_jpeg' => env('AVATAR_PROGRESSIVE_JPEG', true),
// WebP lossless compression
'webp_lossless' => env('AVATAR_WEBP_LOSSLESS', false),
],
/*
|--------------------------------------------------------------------------
| Performance and Caching
|--------------------------------------------------------------------------
| Enhanced caching and performance settings for HD avatars
|
*/
'performance' => [
// Enable file-based caching in addition to memory cache
'file_cache' => env('AVATAR_FILE_CACHE', true),
// Cache different sizes separately
'size_based_cache' => env('AVATAR_SIZE_CACHE', true),
// Preload fonts for better performance
'preload_fonts' => env('AVATAR_PRELOAD_FONTS', true),
// Background processing for large batches
'background_processing' => env('AVATAR_BACKGROUND_PROCESSING', false),
// Lazy loading support
'lazy_loading' => env('AVATAR_LAZY_LOADING', true),
// Compression levels
'compression' => [
'png' => env('AVATAR_PNG_COMPRESSION', 6), // 0-9
'webp' => env('AVATAR_WEBP_COMPRESSION', 80), // 0-100
],
],
/*
|--------------------------------------------------------------------------
| Storage Management
|--------------------------------------------------------------------------
| Configuration for storage optimization and cleanup
|
*/
'storage' => [
// Automatic cleanup of old files
'auto_cleanup' => env('AVATAR_AUTO_CLEANUP', true),
// Maximum age for cached files (in days)
'max_age_days' => env('AVATAR_MAX_AGE_DAYS', 30),
// Maximum storage size (in MB, 0 = unlimited)
'max_storage_mb' => env('AVATAR_MAX_STORAGE_MB', 500),
// Storage driver (local, s3, etc.)
'disk' => env('AVATAR_STORAGE_DISK', 'local'),
// CDN URL for serving images
'cdn_url' => env('AVATAR_CDN_URL', null),
// Enable storage metrics
'metrics' => env('AVATAR_STORAGE_METRICS', false),
],
/*
|--------------------------------------------------------------------------
| HD Themes
|--------------------------------------------------------------------------
| Enhanced themes with HD-specific optimizations
|
*/
'hd_themes' => [
'ultra-hd' => [
'width' => 1024,
'height' => 1024,
'fontSize' => 384,
'backgrounds' => [
'#667eea', '#764ba2', '#f093fb', '#f5576c',
'#4facfe', '#00f2fe', '#43e97b', '#38f9d7',
'#ffecd2', '#fcb69f', '#a8edea', '#fed6e3',
],
'foregrounds' => ['#FFFFFF'],
'border' => [
'size' => 4,
'color' => 'foreground',
'radius' => 8,
],
],
'retina' => [
'width' => 512,
'height' => 512,
'fontSize' => 192,
'backgrounds' => [
'#667eea', '#764ba2', '#f093fb', '#f5576c',
'#4facfe', '#00f2fe', '#43e97b', '#38f9d7',
],
'foregrounds' => ['#FFFFFF'],
],
'material-hd' => [
'width' => 384,
'height' => 384,
'fontSize' => 144,
'shape' => 'circle',
'backgrounds' => [
'#1976D2', '#388E3C', '#F57C00', '#7B1FA2',
'#5D4037', '#455A64', '#E64A19', '#00796B',
],
'foregrounds' => ['#FFFFFF'],
'border' => [
'size' => 2,
'color' => 'background',
'radius' => 0,
],
],
],
/*
|--------------------------------------------------------------------------
| Responsive Sizes
|--------------------------------------------------------------------------
| Predefined sizes for responsive avatar generation
|
*/
'responsive_sizes' => [
'thumbnail' => ['width' => 64, 'height' => 64, 'fontSize' => 24],
'small' => ['width' => 128, 'height' => 128, 'fontSize' => 48],
'medium' => ['width' => 256, 'height' => 256, 'fontSize' => 96],
'large' => ['width' => 512, 'height' => 512, 'fontSize' => 192],
'xl' => ['width' => 768, 'height' => 768, 'fontSize' => 288],
'xxl' => ['width' => 1024, 'height' => 1024, 'fontSize' => 384],
],
/*
|--------------------------------------------------------------------------
| Advanced Features
|--------------------------------------------------------------------------
| Additional HD avatar features
|
*/
'features' => [
// Generate avatar sprites for animations
'sprites' => env('AVATAR_SPRITES', false),
// Generate avatar variations (different colors/styles)
'variations' => env('AVATAR_VARIATIONS', false),
// Generate blur placeholder images
'placeholders' => env('AVATAR_PLACEHOLDERS', true),
// Generate different aspect ratios
'aspect_ratios' => env('AVATAR_ASPECT_RATIOS', false),
// Watermarking support
'watermark' => [
'enabled' => env('AVATAR_WATERMARK', false),
'text' => env('AVATAR_WATERMARK_TEXT', ''),
'opacity' => env('AVATAR_WATERMARK_OPACITY', 0.3),
'position' => env('AVATAR_WATERMARK_POSITION', 'bottom-right'),
],
],
/*
|--------------------------------------------------------------------------
| API Settings
|--------------------------------------------------------------------------
| Configuration for avatar API endpoints
|
*/
'api' => [
// Enable avatar API endpoints
'enabled' => env('AVATAR_API_ENABLED', true),
// Rate limiting (requests per minute)
'rate_limit' => env('AVATAR_API_RATE_LIMIT', 60),
// Enable CORS for API endpoints
'cors' => env('AVATAR_API_CORS', true),
// API authentication
'auth' => env('AVATAR_API_AUTH', false),
// Response headers
'headers' => [
'Cache-Control' => 'public, max-age=31536000', // 1 year
'Expires' => gmdate('D, d M Y H:i:s', time() + 31536000).' GMT',
],
],
];

174
config/laravolt/avatar.php Normal file
View File

@@ -0,0 +1,174 @@
<?php
/*
* Set specific configuration variables here
*/
return [
/*
|--------------------------------------------------------------------------
| Image Driver
|--------------------------------------------------------------------------
| Avatar use Intervention Image library to process image.
| Meanwhile, Intervention Image supports "GD Library" and "Imagick" to process images
| internally. You may choose one of them according to your PHP
| configuration. By default PHP's "GD Library" implementation is used.
|
| Supported: "gd", "imagick"
|
*/
'driver' => env('IMAGE_DRIVER', 'gd'),
/*
|--------------------------------------------------------------------------
| Cache Configuration
|--------------------------------------------------------------------------
| Control caching behavior for avatars
|
*/
'cache' => [
// Set to true to enable caching, false to disable
'enabled' => env('AVATAR_CACHE_ENABLED', true),
// Cache prefix to avoid conflicts with other cached items
'key_prefix' => 'avatar_',
// Cache duration in seconds
// Set to null to cache forever, 0 to disable cache
// Default: 86400 (24 hours)
'duration' => env('AVATAR_CACHE_DURATION', 86400),
],
// Initial generator class
'generator' => \Laravolt\Avatar\Generator\DefaultGenerator::class,
// Whether all characters supplied must be replaced with their closest ASCII counterparts
'ascii' => false,
// Image shape: circle or square
'shape' => 'circle',
// Image width, in pixel
'width' => 100,
// Image height, in pixel
'height' => 100,
// Responsive SVG, height and width attributes are not added when true
'responsive' => false,
// Number of characters used as initials. If name consists of single word, the first N character will be used
'chars' => 2,
// font size
'fontSize' => 48,
// convert initial letter in uppercase
'uppercase' => false,
// Right to Left (RTL)
'rtl' => false,
// Fonts used to render text.
// If contains more than one fonts, randomly selected based on name supplied
'fonts' => [__DIR__.'/../fonts/OpenSans-Bold.ttf', __DIR__.'/../fonts/rockwell.ttf'],
// List of foreground colors to be used, randomly selected based on name supplied
'foregrounds' => [
'#FFFFFF',
],
// List of background colors to be used, randomly selected based on name supplied
'backgrounds' => [
'#f44336',
'#E91E63',
'#9C27B0',
'#673AB7',
'#3F51B5',
'#2196F3',
'#03A9F4',
'#00BCD4',
'#009688',
'#4CAF50',
'#8BC34A',
'#CDDC39',
'#FFC107',
'#FF9800',
'#FF5722',
],
'border' => [
'size' => 1,
// border color, available value are:
// 'foreground' (same as foreground color)
// 'background' (same as background color)
// or any valid hex ('#aabbcc')
'color' => 'background',
// border radius, currently only work for SVG
'radius' => 0,
],
// List of theme name to be used when rendering avatar
// Possible values are:
// 1. Theme name as string: 'colorful'
// 2. Or array of string name: ['grayscale-light', 'grayscale-dark']
// 3. Or wildcard "*" to use all defined themes
'theme' => ['colorful'],
// Predefined themes
// Available theme attributes are:
// shape, chars, backgrounds, foregrounds, fonts, fontSize, width, height, ascii, uppercase, and border.
'themes' => [
'grayscale-light' => [
'backgrounds' => ['#edf2f7', '#e2e8f0', '#cbd5e0'],
'foregrounds' => ['#a0aec0'],
],
'grayscale-dark' => [
'backgrounds' => ['#2d3748', '#4a5568', '#718096'],
'foregrounds' => ['#e2e8f0'],
],
'colorful' => [
'backgrounds' => [
'#f44336',
'#E91E63',
'#9C27B0',
'#673AB7',
'#3F51B5',
'#2196F3',
'#03A9F4',
'#00BCD4',
'#009688',
'#4CAF50',
'#8BC34A',
'#CDDC39',
'#FFC107',
'#FF9800',
'#FF5722',
],
'foregrounds' => ['#FFFFFF'],
],
'pastel' => [
'backgrounds' => [
'#ef9a9a',
'#F48FB1',
'#CE93D8',
'#B39DDB',
'#9FA8DA',
'#90CAF9',
'#81D4FA',
'#80DEEA',
'#80CBC4',
'#A5D6A7',
'#E6EE9C',
'#FFAB91',
'#FFCCBC',
'#D7CCC8',
],
'foregrounds' => [
'#FFF',
],
],
],
];