diff --git a/video_cli/cli/tile.py b/video_cli/cli/tile.py index 78bfca1..d190b1f 100644 --- a/video_cli/cli/tile.py +++ b/video_cli/cli/tile.py @@ -49,7 +49,8 @@ def tile(in_files, out, resize=1, shape=None, duration="max"): break if images_blank is None: images_blank = [np.zeros_like(img) for img in images] - img = imgviz.tile(images, shape=shape, border=(255, 255, 255)) + row, col = shape if shape is not None else (None, None) + img = imgviz.tile(images, row=row, col=col, border=(255, 255, 255)) img = utils.resize_to_even(img) if writer is None: writer = imageio.get_writer( diff --git a/video_cli/utils/resize_to_even.py b/video_cli/utils/resize_to_even.py index 25eb7c9..1e20e99 100644 --- a/video_cli/utils/resize_to_even.py +++ b/video_cli/utils/resize_to_even.py @@ -1,11 +1,18 @@ import math -import imgviz +import numpy as np def resize_to_even(image): height, width = image.shape[:2] - height = math.ceil(height / 2) * 2 - width = math.ceil(width / 2) * 2 - image = imgviz.centerize(image, (height, width)) + height_even = math.ceil(height / 2) * 2 + width_even = math.ceil(width / 2) * 2 + pad_h = height_even - height + pad_w = width_even - width + top = pad_h // 2 + left = pad_w // 2 + pads = ((top, pad_h - top), (left, pad_w - left)) + if image.ndim == 3: + pads += ((0, 0),) + image = np.pad(image, pads, mode="constant") return image