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

Horizontally fit or center images #9

Merged
merged 1 commit into from
Oct 26, 2020
Merged

Horizontally fit or center images #9

merged 1 commit into from
Oct 26, 2020

Conversation

kubuzetto
Copy link
Contributor

@kubuzetto kubuzetto commented Oct 26, 2020

The original code only checks that the image fits the screen vertically. If the image aspect ratio is wider than of the terminal window; then line wrapping will occur and the image will be distorted.

This patch also keeps track of terminal width; and attempts to fit the image in both directions using the resize.Thumbnail function instead of resize.Resize.

chg0
Left: Original, Right: Fitted

I also horizontally center the image if the width is wider:
chg1

@trashhalo
Copy link
Owner

:O no ones ever fixed a bug on one of my repos before...

@trashhalo trashhalo merged commit 6969df1 into trashhalo:master Oct 26, 2020
@trashhalo
Copy link
Owner

Your fix was included in v1.1.0. https://github.com/trashhalo/imgcat/releases/tag/v1.1.0

@kubuzetto kubuzetto deleted the fitwidth branch October 27, 2020 08:12
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