# smartcrop.rs [![Current crates.io version](https://img.shields.io/crates/v/smartcrop2.svg)](https://crates.io/crates/smartcrop2) [![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat)](http://opensource.org/licenses/MIT) [![CI status](https://codeberg.org/ThetaDev/smartcrop.rs/actions/workflows/ci.yaml/badge.svg?style=flat&label=CI)](https://codeberg.org/ThetaDev/smartcrop.rs/actions/?workflow=ci.yaml) Smartcrop is a content-aware image cropping library that attempts to find the best crop for a given image and aspect ratio. The original Javascript implementation [smartcrop.js](https://github.com/jwagner/smartcrop.js/) was developed by Jonas Wagner. This is a fork of by Bekh-Ivanov Aleksey, since the original project is unmaintained and does not support newer versions of the image crate. ## How to use ```rust ignore let height = 1920; let width = 1080; let res = smartcrop::find_best_crop( &image, NonZeroU32::new(height).unwrap(), NonZeroU32::new(width).unwrap() ).expect("Failed to find crop"); let c = res.crop; let cropped = image.crop_imm(c.x, c.y, c.width, c.height); let scaled = cropped.resize(width, height, image::imageops::FilterType::Lanczos3); ```