diff --git a/autoload.php b/autoload.php index 7a60a1c..daf1072 100644 --- a/autoload.php +++ b/autoload.php @@ -44,6 +44,7 @@ require_once(__DIR__ . '/deployer/requirements/task/check_locales.php'); require_once(__DIR__ . '/deployer/requirements/task/check_packages.php'); require_once(__DIR__ . '/deployer/requirements/task/check_image_processing.php'); +require_once(__DIR__ . '/deployer/requirements/task/check_media_support.php'); require_once(__DIR__ . '/deployer/requirements/task/check_php_extensions.php'); require_once(__DIR__ . '/deployer/requirements/task/check_php_settings.php'); require_once(__DIR__ . '/deployer/requirements/task/check_database.php'); diff --git a/deployer/requirements/config/set.php b/deployer/requirements/config/set.php index 56da57d..93a1191 100644 --- a/deployer/requirements/config/set.php +++ b/deployer/requirements/config/set.php @@ -11,6 +11,7 @@ set('requirements_check_locales_enabled', true); set('requirements_check_packages_enabled', true); set('requirements_check_image_processing_enabled', true); +set('requirements_check_media_support_enabled', true); set('requirements_check_php_extensions_enabled', true); set('requirements_check_php_settings_enabled', true); set('requirements_check_database_enabled', true); diff --git a/deployer/requirements/task/check_media_support.php b/deployer/requirements/task/check_media_support.php new file mode 100644 index 0000000..7f4028d --- /dev/null +++ b/deployer/requirements/task/check_media_support.php @@ -0,0 +1,123 @@ +hidden(); + +function checkGdFormatSupport(): void +{ + $formats = ['AVIF' => 'AVIF Support', 'WebP' => 'WebP Support']; + + try { + $gdJson = run('php -r "echo function_exists(\'gd_info\') ? json_encode(gd_info()) : \'null\';" 2>/dev/null'); + } catch (RunException) { + foreach ($formats as $label => $key) { + addRequirementRow("GD: $label Support", REQUIREMENT_SKIP, 'Could not query GD'); + } + + return; + } + + $gdInfo = json_decode($gdJson, true); + + if (!is_array($gdInfo)) { + foreach ($formats as $label => $key) { + addRequirementRow("GD: $label Support", REQUIREMENT_SKIP, 'GD not available'); + } + + return; + } + + foreach ($formats as $label => $key) { + $supported = !empty($gdInfo[$key]); + addRequirementRow( + "GD: $label Support", + $supported ? REQUIREMENT_OK : REQUIREMENT_WARN, + $supported ? 'Supported' : 'Not compiled into GD' + ); + } +} + +function checkImageToolFormatSupport(): void +{ + $formats = ['AVIF' => 'AVIF', 'WEBP' => 'WebP']; + $formatList = null; + $toolLabel = null; + + // Try GraphicsMagick first + try { + $output = run('gm convert -list format 2>/dev/null'); + + if ('' !== trim($output)) { + $formatList = $output; + $toolLabel = 'GraphicsMagick'; + } + } catch (RunException) { + // not available + } + + // Fallback to ImageMagick + if (null === $formatList) { + foreach (['magick', 'convert'] as $imCommand) { + try { + $output = run("$imCommand -list format 2>/dev/null"); + + if ('' !== trim($output)) { + $formatList = $output; + $toolLabel = 'ImageMagick'; + + break; + } + } catch (RunException) { + continue; + } + } + } + + if (null === $formatList || null === $toolLabel) { + foreach ($formats as $label) { + addRequirementRow("IM/GM: $label", REQUIREMENT_SKIP, 'No image processing tool found'); + } + + return; + } + + foreach ($formats as $formatKey => $label) { + $supported = (bool) preg_match('/^\s*' . $formatKey . '\b/mi', $formatList); + addRequirementRow( + "IM/GM: $label", + $supported ? REQUIREMENT_OK : REQUIREMENT_WARN, + $supported ? "Supported ($toolLabel)" : "Format not supported ($toolLabel)" + ); + } +} + +function checkBrotliExtension(): void +{ + try { + $modules = strtolower(run('php -m 2>/dev/null')); + } catch (RunException) { + addRequirementRow('PHP ext: brotli', REQUIREMENT_SKIP, 'Could not retrieve PHP modules'); + + return; + } + + $loaded = in_array('brotli', array_map('trim', explode("\n", $modules)), true); + addRequirementRow( + 'PHP ext: brotli', + $loaded ? REQUIREMENT_OK : REQUIREMENT_WARN, + $loaded ? 'Loaded' : 'Not loaded' + ); +} diff --git a/deployer/requirements/task/requirements.php b/deployer/requirements/task/requirements.php index 20cba39..34bc9aa 100644 --- a/deployer/requirements/task/requirements.php +++ b/deployer/requirements/task/requirements.php @@ -8,6 +8,7 @@ 'requirements:check:locales', 'requirements:check:packages', 'requirements:check:image_processing', + 'requirements:check:media_support', 'requirements:check:php_extensions', 'requirements:check:php_settings', 'requirements:check:database', diff --git a/docs/REQUIREMENTS.md b/docs/REQUIREMENTS.md index 3b40e49..63b8cf1 100644 --- a/docs/REQUIREMENTS.md +++ b/docs/REQUIREMENTS.md @@ -21,7 +21,6 @@ $ dep requirements:list [host] ## Checks ### Locales - Verifies that required system locales are available (default: `de_DE.utf8`, `en_US.utf8`). ### System packages @@ -32,6 +31,20 @@ Checks for required CLI tools: rsync, curl, ghostscript, git, gzip, mariadb-clie Checks for GraphicsMagick (>= 1.3, recommended) or ImageMagick (>= 6.0) with version validation. Either one is sufficient. +### Media support + +Checks for modern media format support across the PHP GD library and the installed image processing tool (GraphicsMagick or ImageMagick): + +| Check | Method | OK | WARN | SKIP | +|-------|--------|----|------|------| +| GD: AVIF Support | `gd_info()` key `AVIF Support` | Supported | Not compiled into GD | GD not available | +| GD: WebP Support | `gd_info()` key `WebP Support` | Supported | Not compiled into GD | GD not available | +| IM/GM: AVIF | Format list (`-list format`) | Supported (tool name) | Format not supported (tool name) | No image processing tool found | +| IM/GM: WebP | Format list (`-list format`) | Supported (tool name) | Format not supported (tool name) | No image processing tool found | +| PHP ext: brotli | `php -m` | Loaded | Not loaded | Could not retrieve PHP modules | + +All checks use WARN (not FAIL) since these features are recommended but not strictly required. + ### PHP version Validates the PHP version against the configured minimum (TYPO3: >= 8.2.0, default: >= 8.1.0). @@ -158,6 +171,9 @@ set('requirements_packages', [ set('requirements_mariadb_min_version', '10.6.0'); set('requirements_mysql_min_version', '8.0.30'); +// Disable media support checks (AVIF, WebP, brotli) +set('requirements_check_media_support_enabled', false); + // Override image processing minimum versions set('requirements_graphicsmagick_min_version', '1.3.30'); set('requirements_imagemagick_min_version', '7.0');