欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

图片缩放

程序员文章站 2024-03-24 12:46:04
...
# 图像缩放
import io
from PIL import Image

def resize_image(ori_img, dst_img):
    pil_image = Image.open(ori_img)    
    # get the size of the image
    ori_w, ori_h = pil_image.size
  
    pil_image_resized = pil_image.resize((ori_w/4, ori_h/4), Image.ANTIALIAS)
    pil_image_resized.save(dst_img)
    
#源图片
ori_img = r'D:\mobile\20150917112239.png'
#目标图片
dst_img = r'D:\python_2.png'
resize_image(ori_img, dst_img)