使用python按图片固定长宽比缩放图片到指定图片大小,空白部分填充为黑色。
代码
# -*- coding: utf-8 -*-
from PIL import Image
class image_aspect():
def __init__(self, image_file, aspect_width, aspect_height):
self.img = Image.open(image_file)
self.aspect_width = aspect_width
self.aspect_height = aspect_height
self.result_image
1