def __init__(self, img, ismask=False, transparent=True,
fromalpha=False, duration=None): # yapf: disable
VideoClip.__init__(self, ismask=ismask, duration=duration)
if isinstance(img, str):
img = imread(img)
if len(img.shape) == 3: # img is (now) a RGB(a) numpy array
if img.shape[2] == 4:
if fromalpha:
img = 1.0 * img[:, :, 3] / 255
elif ismask:
img = 1.0 * img[:, :, 0] / 255
elif transparent:
self.mask = ImageClip(
1.0 * img[:, :, 3] / 255, ismask=True)
img = img[:, :, :3]
elif ismask:
img = 1.0 * img[:, :, 0] / 255
# if the image was just a 2D mask, it should arrive here
# unchanged
self.make_frame = lambda t: img
self.size = img.shape[:2][::-1]
self.img = img
评论列表
文章目录