Image optimization

Processed images are optimized by default when they are rendered through sGallery::file(). The optimization step runs after resizing, fitting, or cropping, so generated cache files stay as small as possible.

Slow uncached transformations can be handed to the optional sTask worker while the frontend serves the original. See background image optimization for the cooperative time budget, heartbeat requirements and cache recovery.

$image = sGallery::file($gallery->path)->fit('crop', 592, 320);

You can disable optimization for a specific image when the output should be left untouched.

$image = sGallery::file($gallery->path)
    ->optimize(false)
    ->fit('crop', 592, 320);

Use sharpen() when a resized or cropped image needs a small clarity boost. The accepted value is from 0 to 100.

$image = sGallery::file($gallery->path)
    ->fit('crop', 592, 320)
    ->sharpen(10);

Optimization and sharpening are included in the generated cache file name, so changing these options creates a separate cached derivative.