SLPS CENTRAL IMAGE OPTIMISATION — V33

Purpose
New uploaded still images in the integrated SLPS upload areas are converted to WebP, resized when larger than the target bounds, and compressed. Documents, video, ZIP/RAR archives, PDFs and animated GIFs are not converted.

Central service
- shared/lib/image_optimizer.php
- Uses Imagick with WebP support when available; otherwise GD imagewebp().
- Accepts JPEG, PNG and WebP source images.
- Preserves transparency for PNG/WebP.
- Attempts to respect JPEG EXIF orientation.
- Resizes to fit within the endpoint's target dimensions without upscaling.
- Uses WebP quality 82 by default.
- If the host has no working WebP encoder or conversion fails, the original image is retained to avoid data loss.

Integrated upload areas
1. Department Files / shared file upload (image/jpeg, image/png, image/webp).
2. Post News article resources and cover images (stored as WebP BLOB with image/webp MIME).
3. Practical Guidelines image resources (private storage key .webp and image/webp media type).
4. Personal Files chunked uploads (JPEG/PNG/WebP are converted at final chunk; metadata and quota reflect compressed size).
5. Data Collections cover images (public preview images are stored as WebP).

Processing limits
- Standard upload image targets: 1920 × 1920 pixels, quality 82.
- Data Collection cover targets: 1600 × 1600 pixels, quality 82.
- The source image is validated before conversion.
- GIF animation is preserved by leaving GIF files untouched.
- Other file types are not modified.

Important compatibility
- Existing uploaded files are not batch-converted by this release; conversion applies to new uploads.
- The service requires either Imagick with WEBP support or GD with imagewebp().
- If neither is enabled, uploads still work using original formats.
- Enable WebP support in the same PHP version used by the website in cPanel (MultiPHP INI Editor / Select PHP Version or ask hosting support).
- PHP memory_limit must be adequate for the maximum permitted upload image dimensions.

Hosting diagnostics (run in the same PHP version as the SLPS site):
  var_dump(extension_loaded('gd'), function_exists('imagewebp'),
           class_exists('Imagick'),
           class_exists('Imagick') ? Imagick::queryFormats('WEBP') : []);

Installation
1. Back up application files and database.
2. Upload V33 preserving slps/ paths and overwrite the listed endpoints.
3. No database migration is required.
4. Hard refresh the browser after deployment.
5. Upload one JPEG and one PNG in each relevant area and inspect the stored MIME type / filename.
6. Verify transparent PNGs, landscape images and portrait images.

Validation
- PHP syntax and ZIP integrity checks are performed locally.
- The build environment cannot verify the hosting server's GD/Imagick configuration.
- No live production upload test has been performed.
