GeniXCMS

Image Class

categoryAPI edit_calendar31 Mar 2026

Image Processing & Asset Optimization Class


The Image class is the primary visual asset engine for GeniXCMS. It provides high-performance, on-the-fly thumbnail generation with intelligent caching, multi-format conversion (WebP, AVIF), cropping utilities, and automated watermark injection powered by the Intervention Image v3 library.


⚡ Integrated Thumbnail Engine

GeniXCMS features a "just-in-time" thumbnail system. Images are processed only upon first request and then served as static files from the assets/cache/ directory for sub-second performance.

Image::thumbFly(string $src, ...)

The modern, recommended thumbnail generator.

Parameter Type Default Description
$src string Required Relative path to the original source image.
$type string 'square' Resize mode: 'square' (crop), 'large', or 'small'.
$size int 150 The target pixel dimension.
$align string 'center' Crop alignment (top, bottom, left, right).

🎨 Conversion & Format Optimization

Future-proof your designs with automated next-generation format conversion.

Image::convertWebp(string $path)

Translates any local image asset into the WebP format.

  • Quality: Compresses at a high-efficiency 65% quality.
  • Output: Saves the result as {filename}.webp in the same directory.

Image::compressPng(string $path)

Re-compresses PNG files using the GD driver at level 9 while maintaining full alpha transparency.


🏗️ Standard Transformation Tools

For manual asset manipulation within modules or themes.

Image::resize(string $src, string $dst, int $w, int $h, bool $crop = false)

A native GD-based utility for creating explicit file copies with new dimensions.

// Center-crop a hero image to exactly 1200x400
Image::resize($original, $banner, 1200, 400, true);

🏹 Smart URL Pattern (Dynamic Assets)

Thumbnails can be retrieved dynamically via human-readable URL paths resolved by the Router.

  • Square Icon: /thumb/type/square/size/80/uploads/my-photo.jpg
  • Large Preview: /thumb/type/large/size/800/uploads/banner.png
  • Simple Size: /thumb/size/300/uploads/logo.jpg

🛠️ Security & Integrity

  • Files::isClean(): Every image request is scanned to ensure the target is a valid media file and does not contain embedded malicious code.
  • Watermark Engine: If media_use_watermark is enabled, images larger than 200px automatically receive the configured brand overlay.

priority_high
ImportantServer Requirements: This class requires the PHP GD Extension (with WebP support) and at least 128MB of PHP Memory to process high-resolution uploads comfortably.

lightbulb
TipGravatar Support: Use Image::getGravatar(string $email) to automatically fetch and cache global user avatars based on the site's privacy settings.

See Also