Python/短视频合成自动化/image.py

27 lines
491 B
Python

# -*- coding: utf-8 -*-
"""
生成图片模块
"""
# 列举导入模块
import cv2
import numpy
from pathlib import Path
# 创建画布(默认填充为白色)
canvas = numpy.ones((1080, 1920, 3), dtype=numpy.uint8) * 255
# 当前文件夹路径
current_path = Path(__file__).parent
# 构建生成图片路径
image_path = current_path / "111.jpg"
print(image_path)
success = cv2.imwrite(
filename=image_path, img=canvas, params=[cv2.IMWRITE_JPEG_QUALITY, 95]
)
print(success)