chore: complete update
This commit is contained in:
40
src/Domain/Media/ImageProcessorFactory.php
Normal file
40
src/Domain/Media/ImageProcessorFactory.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Domain\Media;
|
||||
|
||||
/**
|
||||
* Factory-Klasse zum Erstellen des richtigen ImageProcessor
|
||||
*/
|
||||
final readonly class ImageProcessorFactory
|
||||
{
|
||||
/**
|
||||
* Erstellt den optimalen ImageProcessor je nach verfügbaren Extensions
|
||||
*
|
||||
* @return ImageProcessorInterface Die beste verfügbare Implementation
|
||||
*/
|
||||
public static function create(): ImageProcessorInterface
|
||||
{
|
||||
// Prüfen ob ImageMagick verfügbar ist
|
||||
if (extension_loaded('imagick') && class_exists('\Imagick')) {
|
||||
try {
|
||||
// Test ob ImageMagick funktioniert
|
||||
$test = new \Imagick();
|
||||
$test->clear();
|
||||
return new ImagickImageProcessor();
|
||||
} catch (\Exception $e) {
|
||||
error_log('ImageMagick is installed but not working: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback auf GD
|
||||
if (extension_loaded('gd') && function_exists('imagecreatetruecolor')) {
|
||||
return new GdImageProcessor();
|
||||
}
|
||||
|
||||
throw new \RuntimeException(
|
||||
'No image processing library available. ' .
|
||||
'Please install and enable either the ImageMagick or GD PHP extension.'
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user