python - moviepy ValueError: operands could not be broadcast together with shapes
问题描述
I want to add vfx.fadein for my ImageClip for that my code snipped :
def rectangle():
size = (surfaceW,surfaceH)
radius = background_radius
fill = background_text_color
width, height = size
rectangle = Image.new('RGBA', size, fill)
corner = round_corner(radius, fill)
rectangle.paste(corner, (0, 0))
rectangle.paste(corner.rotate(90), (0, height - radius))
rectangle.paste(corner.rotate(180), (width - radius, height - radius))
rectangle.paste(corner.rotate(270), (width - radius, 0))
pix = numpy.array(rectangle)
return pix =====================>>>>((75, 601, 4))
image = ImageClip(rectangle(), duration=duration_time).set_start(start_point).set_position(position)
print(image.__dict__["img"].shape) ===========>>>>((75, 601, 3))
image = vfx.fadein(image,duration=1, initial_color=[0,0,0,0]) =====> Error Line
But Im getting this error;
ValueError: operands could not be broadcast together with shapes (75,601,3) (4,)
I want to use vfx.fadein with transparant background so I need use alpha channel. How can solve this?
解决方案
推荐阅读
- php - 使用 Guzzle 客户端的 Laravel OAuth 2.0 身份验证
- python - 在 Django 管理站点中自定义外键下拉列表
- php - 在php数组中删除过去的日期?
- c# - Can't Upload a File to QnaMaker Knowledge Base using SDK
- android - 从某个帧循环 Lottie 动画
- java - 在屏幕帮助上保持形状,无法弄清楚如何跟踪 X、Y 坐标
- python - 共识/集群一组 Python 中的可变长度列表?
- c++ - 使用 cmake 对特定文件进行预验证或后验证
- azure - Azure 逻辑应用,解析 JSON,但可能为空
- ios - 在 tableview 单元格中正确包装文本