benjajaja / ratatui-image

Ratatui widget for rendering image graphics in terminals that support it
https://crates.io/crates/ratatui-image
MIT License
96 stars 14 forks source link

Clip from top #26

Closed dzfrias closed 2 months ago

dzfrias commented 2 months ago

Hello! Thank you for making such a great crate; it's been a life-saver for automatically handling terminal emulator inconsistencies. I was wondering if it was possible to clip an image from the top, instead of the bottom.

For example, if I have an image that doesn't fit inside it's containing Rect (and I've set it Resize::Crop), I want the top of the image to be cut off, not the bottom. Let me know if this is possible, and if it isn't, where I could look to implement it and write a PR.

benjajaja commented 2 months ago

Currently it's hardcoded, but an option could be added to Resize::Crop similar to what Fit has. The actual cropping happens here: https://github.com/benjajaja/ratatui-image/blob/master/src/lib.rs#L291

dzfrias commented 2 months ago

Okay, thank you! I'll work on a PR implementing something soon.

benjajaja commented 2 months ago

closed by #27