added watermark settings tab on the branding page and added more package details to the billing page, added a new guest notifications page

This commit is contained in:
Codex Agent
2025-12-17 16:39:25 +01:00
parent efe697f155
commit 5f3e7ae8c8
25 changed files with 2062 additions and 202 deletions

View File

@@ -33,6 +33,7 @@ class ImageHelper
$h = imagesy($src);
if ($w === 0 || $h === 0) {
imagedestroy($src);
return null;
}
@@ -138,18 +139,44 @@ class ImageHelper
$x = $padding;
$y = $padding;
if ($position === 'top-right') {
$x = max(0, $srcW - $targetW - $padding);
} elseif ($position === 'bottom-left') {
$y = max(0, $srcH - $targetH - $padding);
} elseif ($position === 'bottom-right') {
$x = max(0, $srcW - $targetW - $padding);
$y = max(0, $srcH - $targetH - $padding);
} elseif ($position === 'center') {
$x = (int) max(0, ($srcW - $targetW) / 2);
$y = (int) max(0, ($srcH - $targetH) / 2);
switch ($position) {
case 'top-right':
$x = max(0, $srcW - $targetW - $padding);
break;
case 'top-center':
$x = (int) max(0, ($srcW - $targetW) / 2);
break;
case 'middle-left':
$y = (int) max(0, ($srcH - $targetH) / 2);
break;
case 'center':
$x = (int) max(0, ($srcW - $targetW) / 2);
$y = (int) max(0, ($srcH - $targetH) / 2);
break;
case 'middle-right':
$x = max(0, $srcW - $targetW - $padding);
$y = (int) max(0, ($srcH - $targetH) / 2);
break;
case 'bottom-left':
$y = max(0, $srcH - $targetH - $padding);
break;
case 'bottom-center':
$x = (int) max(0, ($srcW - $targetW) / 2);
$y = max(0, $srcH - $targetH - $padding);
break;
case 'bottom-right':
$x = max(0, $srcW - $targetW - $padding);
$y = max(0, $srcH - $targetH - $padding);
break;
default:
break;
}
$offsetX = (int) ($config['offset_x'] ?? 0);
$offsetY = (int) ($config['offset_y'] ?? 0);
$x = max(0, min($srcW - $targetW, $x + $offsetX));
$y = max(0, min($srcH - $targetH, $y + $offsetY));
$opacity = max(0.0, min(1.0, (float) ($config['opacity'] ?? 0.25)));
$mergeOpacity = (int) round($opacity * 100); // imagecopymerge uses 0-100

View File

@@ -33,7 +33,7 @@ class WatermarkConfigResolver
}
/**
* @return array{type:string, policy:string, asset?:string, position?:string, opacity?:float, scale?:float, padding?:int}
* @return array{type:string, policy:string, asset?:string, position?:string, opacity?:float, scale?:float, padding?:int, offset_x?:int, offset_y?:int}
*/
public static function resolve(Event $event): array
{
@@ -61,6 +61,8 @@ class WatermarkConfigResolver
'opacity' => $baseSetting?->opacity ?? config('watermark.base.opacity', 0.25),
'scale' => $baseSetting?->scale ?? config('watermark.base.scale', 0.2),
'padding' => $baseSetting?->padding ?? config('watermark.base.padding', 16),
'offset_x' => $baseSetting?->offset_x ?? config('watermark.base.offset_x', 0),
'offset_y' => $baseSetting?->offset_y ?? config('watermark.base.offset_y', 0),
];
$event->loadMissing('eventPackage.package', 'tenant');
@@ -91,6 +93,8 @@ class WatermarkConfigResolver
$opacity = (float) ($source['opacity'] ?? $base['opacity'] ?? 0.25);
$scale = (float) ($source['scale'] ?? $base['scale'] ?? 0.2);
$padding = (int) ($source['padding'] ?? $base['padding'] ?? 16);
$offsetX = (int) ($source['offset_x'] ?? $base['offset_x'] ?? 0);
$offsetY = (int) ($source['offset_y'] ?? $base['offset_y'] ?? 0);
$clamp = static fn (float $value, float $min, float $max) => max($min, min($max, $value));
@@ -102,6 +106,8 @@ class WatermarkConfigResolver
'opacity' => $clamp($opacity, 0.0, 1.0),
'scale' => $clamp($scale, 0.05, 1.0),
'padding' => max(0, $padding),
'offset_x' => max(-500, min(500, $offsetX)),
'offset_y' => max(-500, min(500, $offsetY)),
'serve_originals' => $serveOriginals,
];
}