system.resizer.afterCrop

Enables post processing of cropped images after they've been cropped before the cropping process is finalized (ex. adding watermarks, further optimizing, etc)

Example usage:

Event::listen('system.resizer.afterCrop', function ((\System\Classes\ImageResizer) $resizer, (string) $localTempPath) { // Get the resized image data $croppedImageContents = file_get_contents($localTempPath);

 // Post process the image
 $processedContents = TinyPNG::optimize($croppedImageContents);

 // Place the processed image in the correct location for the resizer to finish processing it
 file_put_contents($localTempPath, $processedContents);

});

Usage

Triggers

Class or file Line
System\Classes\ImageResizer 410
Copyright © 2024 Winter CMS