From 3b3329548f6d894e28be8cd2f01f2aa957d01807 Mon Sep 17 00:00:00 2001 From: qeesung <1245712564@qq.com> Date: Mon, 29 Oct 2018 21:37:41 +0800 Subject: [PATCH] update the logic --- convert/resize.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/convert/resize.go b/convert/resize.go index 5ccc6bb..3b8e8cb 100644 --- a/convert/resize.go +++ b/convert/resize.go @@ -46,31 +46,31 @@ func (handler *ImageResizeHandler) ScaleImage(image image.Image, options *Option newHeight = handler.ScaleHeightByRatio(float64(sz.Max.Y), ratio) } - // fit the screen + //Stretch the picture to overspread the terminal if ratio == 1 && options.FixedWidth == -1 && options.FixedHeight == -1 && - options.FitScreen { - fitWidth, fitHeight, err := handler.CalcProportionalFittingScreenSize(image) + options.StretchedScreen { + screenWidth, screenHeight, err := handler.terminal.ScreenSize() if err != nil { log.Fatal(err) } - newWidth = int(fitWidth) - newHeight = int(fitHeight) + newWidth = int(screenWidth) + newHeight = int(screenHeight) } - //Stretch the picture to overspread the terminal + // fit the screen if ratio == 1 && options.FixedWidth == -1 && options.FixedHeight == -1 && - !options.FitScreen && - options.StretchedScreen { - screenWidth, screenHeight, err := handler.terminal.ScreenSize() + options.FitScreen && + !options.StretchedScreen { + fitWidth, fitHeight, err := handler.CalcProportionalFittingScreenSize(image) if err != nil { log.Fatal(err) } - newWidth = int(screenWidth) - newHeight = int(screenHeight) + newWidth = int(fitWidth) + newHeight = int(fitHeight) } newImage = resize.Resize(uint(newWidth), uint(newHeight), image, resize.Lanczos3) -- 2.45.2