diff options
author | Théo de la Hogue | 2024-04-25 12:27:18 +0200 |
---|---|---|
committer | Théo de la Hogue | 2024-04-25 12:27:18 +0200 |
commit | f207f4e245440c72457eb64b6ba0af45570be228 (patch) | |
tree | 00f71113d7b1e6af2b8127ce17e19ebad0d03007 /src | |
parent | addc275da0fe6edcf3ae8d73ffb4a3d5e3d375f9 (diff) | |
download | argaze-f207f4e245440c72457eb64b6ba0af45570be228.zip argaze-f207f4e245440c72457eb64b6ba0af45570be228.tar.gz argaze-f207f4e245440c72457eb64b6ba0af45570be228.tar.bz2 argaze-f207f4e245440c72457eb64b6ba0af45570be228.tar.xz |
Avoiding resize when no -x option is given.
Diffstat (limited to 'src')
-rw-r--r-- | src/argaze/__main__.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/argaze/__main__.py b/src/argaze/__main__.py index 80f12a3..925adf0 100644 --- a/src/argaze/__main__.py +++ b/src/argaze/__main__.py @@ -36,7 +36,7 @@ parser = argparse.ArgumentParser(description=__doc__.split('-')[0]) parser.add_argument('context_file', metavar='CONTEXT_FILE', type=str, help='JSON context filepath') parser.add_argument('-v', '--verbose', action='store_true', default=False, help='enable verbose mode to print information in console') parser.add_argument('-p', '--pipe_path', metavar='PIPE_PATH', type=str, default=None, help='enable pipe communication to execute external commands') -parser.add_argument('-x', '--display', metavar='DISPLAY', nargs="+", type=int, default=[1920, 1080], help='adapt windows to display dimension') +parser.add_argument('-x', '--display', metavar='DISPLAY', nargs="+", type=int, default=None, help='adapt windows to display dimension') parser.add_argument('--no-window', action='store_true', default=False, help='disable window mode') args = parser.parse_args() @@ -60,13 +60,19 @@ if args.pipe_path is not None: def display(name, image, factor): """Adapt image to display dimension.""" - display_size = tuple(args.display) - height, width, _ = image.shape - image_ratio = width/height + if args.display is not None: - new_image_size = (int(display_size[1] * factor * image_ratio), int(display_size[1] * factor)) + display_size = tuple(args.display) + height, width, _ = image.shape + image_ratio = width/height - cv2.imshow(name, cv2.resize(image, dsize=new_image_size, interpolation=cv2.INTER_LINEAR)) + new_image_size = (int(display_size[1] * factor * image_ratio), int(display_size[1] * factor)) + + cv2.imshow(name, cv2.resize(image, dsize=new_image_size, interpolation=cv2.INTER_LINEAR)) + + else: + + cv2.imshow(name, image) # Load context from JSON file with load(args.context_file) as context: |