From 04562dcaa147b1ae1e0f8f0ba36cbfea0a98c2d4 Mon Sep 17 00:00:00 2001 From: K4YT3X Date: Thu, 10 Sep 2020 13:14:36 -0400 Subject: [PATCH] allow only one of width an height to be specified --- src/upscaler.py | 12 ++++++++++-- src/video2x.py | 6 +----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/upscaler.py b/src/upscaler.py index 167c3f5..4ef8175 100755 --- a/src/upscaler.py +++ b/src/upscaler.py @@ -4,7 +4,7 @@ Name: Video2X Upscaler Author: K4YT3X Date Created: December 10, 2018 -Last Modified: September 9, 2020 +Last Modified: September 10, 2020 Description: This file contains the Upscaler class. Each instance of the Upscaler class is an upscaler on an image or @@ -588,7 +588,15 @@ class Upscaler: # if user specified output resolution # calculate number of passes needed - if self.scale_width is not None and self.scale_height is not None: + if self.scale_width is not None or self.scale_height is not None: + + # scale keeping aspect ratio is only one of width/height is given + if self.scale_width is None: + self.scale_width = self.scale_height / height * width + + elif self.scale_height is None: + self.scale_height = self.scale_width / width * height + self.scale_ratio = 2 # when scaled output resolution is smaller than target output resolution diff --git a/src/video2x.py b/src/video2x.py index 8579099..e4e3501 100755 --- a/src/video2x.py +++ b/src/video2x.py @@ -13,7 +13,7 @@ __ __ _ _ ___ __ __ Name: Video2X Controller Creator: K4YT3X Date Created: Feb 24, 2018 -Last Modified: September 9, 2020 +Last Modified: September 10, 2020 Editor: BrianPetkovsek Last Modified: June 17, 2019 @@ -190,10 +190,6 @@ if video2x_args.ratio is not None and (video2x_args.width is not None or video2x Avalon.error(_('Specify either scaling ratio or scaling resolution, not both')) sys.exit(1) -if bool(video2x_args.width) ^ bool(video2x_args.height): - Avalon.error(_('Only one of scaling width and scaling height is specified')) - sys.exit(1) - # redirect output to both terminal and log file if video2x_args.disable_logging is False: LOGFILE = video2x_args.log