Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve aspect ratio during resizing when the user provides both width and height #52

Merged
merged 2 commits into from
Dec 18, 2023

Conversation

mdesantis
Copy link
Contributor

@mdesantis mdesantis commented Dec 10, 2023

Hello!

First of all, thanks for this simple yet powerful utility :-)

I implemented aspect ratio preservation during resizing when the user provides both width and height dimensions. This way, using imgcat with tools like fzf is just wonderful, for example:

fzf --preview='imgcat --width=$FZF_PREVIEW_COLUMNS --height=$(expr $FZF_PREVIEW_LINES \* 2) --half-height --depth=24bit {}'

immagine

immagine

I added the new CLI option -P|--no-preserve-aspect-ratio to disable it. I made it default to true because it doesn't make much sense to me to shrink an image before viewing it, but it's a breaking change. We may want to make it opt-in instead of opt-out if we care about backward compatibility.

Finally, I ensured height to be greater than zero after resizing, just like it happens for width.

@eddieantonio eddieantonio merged commit 2bd6f64 into eddieantonio:master Dec 18, 2023
4 checks passed
@eddieantonio
Copy link
Owner

Excellent work! LGTM!

@mdesantis mdesantis deleted the preserve-aspect-ratio branch December 18, 2023 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants