Files
michaelschiemer/src/Domain/Media/ImageProcessorFactory.php
Michael Schiemer 55a330b223 Enable Discovery debug logging for production troubleshooting
- Add DISCOVERY_LOG_LEVEL=debug
- Add DISCOVERY_SHOW_PROGRESS=true
- Temporary changes for debugging InitializerProcessor fixes on production
2025-08-11 20:13:26 +02:00

43 lines
1.2 KiB
PHP

<?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.'
);
}
}