1
0
Fork
You've already forked smartcrop.rs
0
Content-aware image cropping for Rust
  • Rust 98.8%
  • Just 1.2%
ThetaDev 87ddb326e5
All checks were successful
Release / Release (push) Successful in 38s
CI / Test (push) Successful in 1m44s
chore(release): release smartcrop2 v0.4.0
2025年03月04日 18:47:52 +01:00
.forgejo/workflows ci: fix release script 2024年07月31日 02:17:51 +02:00
.vscode feat: update crate, add docs 2024年07月31日 01:21:40 +02:00
benches feat: update crate, add docs 2024年07月31日 01:21:40 +02:00
src cleanup comments 2025年03月04日 18:46:59 +01:00
testfiles test: add test images 2025年03月04日 18:24:50 +01:00
tests test: add test images 2025年03月04日 18:24:50 +01:00
.editorconfig feat: update crate, add docs 2024年07月31日 01:21:40 +02:00
.gitignore Add cli interface 2018年05月02日 14:13:07 +02:00
Cargo.toml chore(release): release smartcrop2 v0.4.0 2025年03月04日 18:47:52 +01:00
CHANGELOG.md chore(release): release smartcrop2 v0.4.0 2025年03月04日 18:47:52 +01:00
cliff.toml feat: update crate, add docs 2024年07月31日 01:21:40 +02:00
Justfile feat: update crate, add docs 2024年07月31日 01:21:40 +02:00
LICENSE Change license to MIT 2018年06月05日 18:15:52 +02:00
README.md feat: add cli flag for removing borders 2025年03月04日 18:43:25 +01:00

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);