optimized storefront page and images

This commit is contained in:
2026-09-24 14:12:49 -03:00
parent 8d5a12f212
commit a2439bf43b
517 changed files with 311 additions and 12 deletions

View File

@@ -2,6 +2,9 @@
declare(strict_types=1);
const CATALOG_IMAGE_MAX_DIMENSION = 960;
const CATALOG_IMAGE_WEBP_QUALITY = 76;
$sourceRoot = 'C:\\Users\\ncoronel\\Documents\\catalogo_smep_limpio';
$projectRoot = dirname(__DIR__, 2);
$assetRoot = $projectRoot.'/public/images/tennants/mutual_smep/catalog';
@@ -153,7 +156,7 @@ function compressCatalogImage(string $source, string $destination): void
$width = imagesx($sourceImage);
$height = imagesy($sourceImage);
$scale = min(1, 1200 / max($width, $height));
$scale = min(1, CATALOG_IMAGE_MAX_DIMENSION / max($width, $height));
$targetWidth = max(1, (int) round($width * $scale));
$targetHeight = max(1, (int) round($height * $scale));
$targetImage = imagecreatetruecolor($targetWidth, $targetHeight);
@@ -181,7 +184,7 @@ function compressCatalogImage(string $source, string $destination): void
throw new RuntimeException("Unable to create directory: {$destinationDirectory}");
}
if (! imagewebp($targetImage, $destination, 82)) {
if (! imagewebp($targetImage, $destination, CATALOG_IMAGE_WEBP_QUALITY)) {
throw new RuntimeException("Unable to write WebP image: {$destination}");
}
}