Skip to content

Commit dcaab39

Browse files
committed
Merge branch 'master' into cursor/export-hd-avatar-as-image-for-storage-0175
2 parents a164617 + 083fcbb commit dcaab39

File tree

3 files changed

+253
-2
lines changed

3 files changed

+253
-2
lines changed

config/hd-avatar.php

Lines changed: 253 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,253 @@
1+
<?php
2+
3+
/*
4+
|--------------------------------------------------------------------------
5+
| HD Avatar Configuration
6+
|--------------------------------------------------------------------------
7+
| Configuration for high-definition avatar generation with enhanced
8+
| performance through image export and storage optimization.
9+
|
10+
*/
11+
12+
return [
13+
14+
/*
15+
|--------------------------------------------------------------------------
16+
| HD Image Settings
17+
|--------------------------------------------------------------------------
18+
| Configuration for high-definition avatar generation
19+
|
20+
*/
21+
'hd' => [
22+
// Enable HD mode - when true, uses higher resolution settings
23+
'enabled' => env('AVATAR_HD_ENABLED', true),
24+
25+
// HD dimensions (default: 512x512, supports up to 2048x2048)
26+
'width' => env('AVATAR_HD_WIDTH', 512),
27+
'height' => env('AVATAR_HD_HEIGHT', 512),
28+
29+
// HD font size (scales with dimensions)
30+
'fontSize' => env('AVATAR_HD_FONT_SIZE', 192),
31+
32+
// Export quality settings
33+
'quality' => [
34+
'png' => env('AVATAR_HD_PNG_QUALITY', 95),
35+
'jpg' => env('AVATAR_HD_JPG_QUALITY', 90),
36+
'webp' => env('AVATAR_HD_WEBP_QUALITY', 85),
37+
],
38+
39+
// Anti-aliasing for smoother edges
40+
'antialiasing' => env('AVATAR_HD_ANTIALIASING', true),
41+
42+
// DPI for high-quality rendering
43+
'dpi' => env('AVATAR_HD_DPI', 300),
44+
],
45+
46+
/*
47+
|--------------------------------------------------------------------------
48+
| Export and Storage Settings
49+
|--------------------------------------------------------------------------
50+
| Configuration for image export and storage optimization
51+
|
52+
*/
53+
'export' => [
54+
// Default export format
55+
'format' => env('AVATAR_EXPORT_FORMAT', 'png'), // png, jpg, webp
56+
57+
// Export path (relative to storage/app)
58+
'path' => env('AVATAR_EXPORT_PATH', 'avatars'),
59+
60+
// Filename pattern: {name}, {initials}, {hash}, {timestamp}
61+
'filename_pattern' => env('AVATAR_EXPORT_FILENAME', '{hash}_{timestamp}.{format}'),
62+
63+
// Enable multiple format export
64+
'multiple_formats' => env('AVATAR_EXPORT_MULTIPLE', false),
65+
66+
// Progressive JPEG for better loading
67+
'progressive_jpeg' => env('AVATAR_PROGRESSIVE_JPEG', true),
68+
69+
// WebP lossless compression
70+
'webp_lossless' => env('AVATAR_WEBP_LOSSLESS', false),
71+
],
72+
73+
/*
74+
|--------------------------------------------------------------------------
75+
| Performance and Caching
76+
|--------------------------------------------------------------------------
77+
| Enhanced caching and performance settings for HD avatars
78+
|
79+
*/
80+
'performance' => [
81+
// Enable file-based caching in addition to memory cache
82+
'file_cache' => env('AVATAR_FILE_CACHE', true),
83+
84+
// Cache different sizes separately
85+
'size_based_cache' => env('AVATAR_SIZE_CACHE', true),
86+
87+
// Preload fonts for better performance
88+
'preload_fonts' => env('AVATAR_PRELOAD_FONTS', true),
89+
90+
// Background processing for large batches
91+
'background_processing' => env('AVATAR_BACKGROUND_PROCESSING', false),
92+
93+
// Lazy loading support
94+
'lazy_loading' => env('AVATAR_LAZY_LOADING', true),
95+
96+
// Compression levels
97+
'compression' => [
98+
'png' => env('AVATAR_PNG_COMPRESSION', 6), // 0-9
99+
'webp' => env('AVATAR_WEBP_COMPRESSION', 80), // 0-100
100+
],
101+
],
102+
103+
/*
104+
|--------------------------------------------------------------------------
105+
| Storage Management
106+
|--------------------------------------------------------------------------
107+
| Configuration for storage optimization and cleanup
108+
|
109+
*/
110+
'storage' => [
111+
// Automatic cleanup of old files
112+
'auto_cleanup' => env('AVATAR_AUTO_CLEANUP', true),
113+
114+
// Maximum age for cached files (in days)
115+
'max_age_days' => env('AVATAR_MAX_AGE_DAYS', 30),
116+
117+
// Maximum storage size (in MB, 0 = unlimited)
118+
'max_storage_mb' => env('AVATAR_MAX_STORAGE_MB', 500),
119+
120+
// Storage driver (local, s3, etc.)
121+
'disk' => env('AVATAR_STORAGE_DISK', 'local'),
122+
123+
// CDN URL for serving images
124+
'cdn_url' => env('AVATAR_CDN_URL', null),
125+
126+
// Enable storage metrics
127+
'metrics' => env('AVATAR_STORAGE_METRICS', false),
128+
],
129+
130+
/*
131+
|--------------------------------------------------------------------------
132+
| HD Themes
133+
|--------------------------------------------------------------------------
134+
| Enhanced themes with HD-specific optimizations
135+
|
136+
*/
137+
'hd_themes' => [
138+
'ultra-hd' => [
139+
'width' => 1024,
140+
'height' => 1024,
141+
'fontSize' => 384,
142+
'backgrounds' => [
143+
'#667eea', '#764ba2', '#f093fb', '#f5576c',
144+
'#4facfe', '#00f2fe', '#43e97b', '#38f9d7',
145+
'#ffecd2', '#fcb69f', '#a8edea', '#fed6e3',
146+
],
147+
'foregrounds' => ['#FFFFFF'],
148+
'border' => [
149+
'size' => 4,
150+
'color' => 'foreground',
151+
'radius' => 8,
152+
],
153+
],
154+
'retina' => [
155+
'width' => 512,
156+
'height' => 512,
157+
'fontSize' => 192,
158+
'backgrounds' => [
159+
'#667eea', '#764ba2', '#f093fb', '#f5576c',
160+
'#4facfe', '#00f2fe', '#43e97b', '#38f9d7',
161+
],
162+
'foregrounds' => ['#FFFFFF'],
163+
],
164+
'material-hd' => [
165+
'width' => 384,
166+
'height' => 384,
167+
'fontSize' => 144,
168+
'shape' => 'circle',
169+
'backgrounds' => [
170+
'#1976D2', '#388E3C', '#F57C00', '#7B1FA2',
171+
'#5D4037', '#455A64', '#E64A19', '#00796B',
172+
],
173+
'foregrounds' => ['#FFFFFF'],
174+
'border' => [
175+
'size' => 2,
176+
'color' => 'background',
177+
'radius' => 0,
178+
],
179+
],
180+
],
181+
182+
/*
183+
|--------------------------------------------------------------------------
184+
| Responsive Sizes
185+
|--------------------------------------------------------------------------
186+
| Predefined sizes for responsive avatar generation
187+
|
188+
*/
189+
'responsive_sizes' => [
190+
'thumbnail' => ['width' => 64, 'height' => 64, 'fontSize' => 24],
191+
'small' => ['width' => 128, 'height' => 128, 'fontSize' => 48],
192+
'medium' => ['width' => 256, 'height' => 256, 'fontSize' => 96],
193+
'large' => ['width' => 512, 'height' => 512, 'fontSize' => 192],
194+
'xl' => ['width' => 768, 'height' => 768, 'fontSize' => 288],
195+
'xxl' => ['width' => 1024, 'height' => 1024, 'fontSize' => 384],
196+
],
197+
198+
/*
199+
|--------------------------------------------------------------------------
200+
| Advanced Features
201+
|--------------------------------------------------------------------------
202+
| Additional HD avatar features
203+
|
204+
*/
205+
'features' => [
206+
// Generate avatar sprites for animations
207+
'sprites' => env('AVATAR_SPRITES', false),
208+
209+
// Generate avatar variations (different colors/styles)
210+
'variations' => env('AVATAR_VARIATIONS', false),
211+
212+
// Generate blur placeholder images
213+
'placeholders' => env('AVATAR_PLACEHOLDERS', true),
214+
215+
// Generate different aspect ratios
216+
'aspect_ratios' => env('AVATAR_ASPECT_RATIOS', false),
217+
218+
// Watermarking support
219+
'watermark' => [
220+
'enabled' => env('AVATAR_WATERMARK', false),
221+
'text' => env('AVATAR_WATERMARK_TEXT', ''),
222+
'opacity' => env('AVATAR_WATERMARK_OPACITY', 0.3),
223+
'position' => env('AVATAR_WATERMARK_POSITION', 'bottom-right'),
224+
],
225+
],
226+
227+
/*
228+
|--------------------------------------------------------------------------
229+
| API Settings
230+
|--------------------------------------------------------------------------
231+
| Configuration for avatar API endpoints
232+
|
233+
*/
234+
'api' => [
235+
// Enable avatar API endpoints
236+
'enabled' => env('AVATAR_API_ENABLED', true),
237+
238+
// Rate limiting (requests per minute)
239+
'rate_limit' => env('AVATAR_API_RATE_LIMIT', 60),
240+
241+
// Enable CORS for API endpoints
242+
'cors' => env('AVATAR_API_CORS', true),
243+
244+
// API authentication
245+
'auth' => env('AVATAR_API_AUTH', false),
246+
247+
// Response headers
248+
'headers' => [
249+
'Cache-Control' => 'public, max-age=31536000', // 1 year
250+
'Expires' => gmdate('D, d M Y H:i:s', time() + 31536000) . ' GMT',
251+
],
252+
],
253+
];

src/Concerns/ImageExport.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
trait ImageExport
1616
{
1717
protected array $exportFormats = ['png', 'jpg', 'jpeg', 'webp'];
18-
1918
protected array $exportOptions = [];
2019

2120
/**

tests/HDAvatarResponseTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
class HDAvatarResponseTest extends TestCase
1010
{
1111
protected HDAvatarResponse $hdAvatar;
12-
1312
protected array $config;
1413

1514
protected function setUp(): void

0 commit comments

Comments
 (0)