Content-aware image cropping for Rust
- Rust 98.8%
- Just 1.2%
| .forgejo/workflows | ci: fix release script | |
| .vscode | feat: update crate, add docs | |
| benches | feat: update crate, add docs | |
| src | cleanup comments | |
| testfiles | test: add test images | |
| tests | test: add test images | |
| .editorconfig | feat: update crate, add docs | |
| .gitignore | Add cli interface | |
| Cargo.toml | chore(release): release smartcrop2 v0.4.0 | |
| CHANGELOG.md | chore(release): release smartcrop2 v0.4.0 | |
| cliff.toml | feat: update crate, add docs | |
| Justfile | feat: update crate, add docs | |
| LICENSE | Change license to MIT | |
| README.md | feat: add cli flag for removing borders | |
smartcrop.rs
Current crates.io version License CI status
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 was developed by Jonas Wagner.
This is a fork of https://github.com/bekh6ex/smartcrop.rs by Bekh-Ivanov Aleksey, since the original project is unmaintained and does not support newer versions of the image crate.
It also includes a new feature: removing black borders around an image before finding the best crop.
How to use
letheight=1920;letwidth=1080;letres=smartcrop::find_best_crop(&image,NonZeroU32::new(height).unwrap(),NonZeroU32::new(width).unwrap()).expect("Failed to find crop");letc=res.crop;letcropped=image.crop_imm(c.x,c.y,c.width,c.height);letscaled=cropped.resize(width,height,image::imageops::FilterType::Lanczos3);