Les administrateurs peuvent désormais configurer l'identité visuelle de leur établissement : upload d'un logo (PNG/JPG, redimensionné automatiquement via Imagick) et choix d'une couleur principale appliquée aux boutons et à la navigation. La couleur est validée côté client et serveur pour garantir la conformité WCAG AA (contraste ≥ 4.5:1 sur fond blanc). Les personnalisations sont injectées dynamiquement via CSS variables et visibles immédiatement après sauvegarde.
40 lines
1.1 KiB
PHP
40 lines
1.1 KiB
PHP
<?php
|
||
|
||
declare(strict_types=1);
|
||
|
||
namespace App\Administration\Infrastructure\Storage;
|
||
|
||
use App\Administration\Application\Port\ImageProcessor;
|
||
use App\Administration\Domain\Exception\LogoTraitementImpossibleException;
|
||
use Imagick;
|
||
use ImagickException;
|
||
use Override;
|
||
|
||
/**
|
||
* Redimensionne les images via ImageMagick (ext-imagick).
|
||
*
|
||
* Conserve les proportions : l'image résultante tient dans
|
||
* la boîte maxWidth × maxHeight sans être déformée.
|
||
* Le résultat est toujours au format PNG.
|
||
*/
|
||
final class ImagickImageProcessor implements ImageProcessor
|
||
{
|
||
#[Override]
|
||
public function resize(string $sourcePath, int $maxWidth, int $maxHeight): string
|
||
{
|
||
try {
|
||
$image = new Imagick($sourcePath);
|
||
|
||
$image->thumbnailImage($maxWidth, $maxHeight, true);
|
||
$image->setImageFormat('png');
|
||
|
||
$content = $image->getImageBlob();
|
||
$image->destroy();
|
||
|
||
return $content;
|
||
} catch (ImagickException $e) {
|
||
throw LogoTraitementImpossibleException::pourErreur($e);
|
||
}
|
||
}
|
||
}
|