~dricottone/image2ascii

3b3329548f6d894e28be8cd2f01f2aa957d01807 — qeesung 6 years ago 8ba2681
update the logic
1 files changed, 11 insertions(+), 11 deletions(-)

M convert/resize.go
M convert/resize.go => convert/resize.go +11 -11
@@ 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)