module

CrImage::Util::SmartCrop

Smart cropping that preserves important image content

Unlike simple center cropping, smart crop analyzes the image to find the most interesting region to keep when resizing to a different aspect ratio.

Class methods

crop(src : Image, target_width : Int32, target_height : Int32, strategy : CropStrategy = CropStrategy::Entropy) : Image

Performs smart crop to target dimensions

Analyzes the image to find the most interesting region and crops to it. Useful for generating thumbnails that preserve important content.

img = CrImage.read("photo.jpg")
thumbnail = img.smart_crop(800, 600)
Source