python修改图像分辨率大小
图像分辨率的大小会影响到我们实验的进行,修改合适的分辨率可以让实验完美的进行下去。# -*- codeing = utf-8 -*-# @Time : 2022/5/1 13:23# @Author : ning# @File : 5.1demo.py# @software : PyCharmimport matplotlib.pyplot as pltfrom PIL import Imaged
·
图像分辨率指图像中存储的信息量,是每英寸图像内有多少个像素点,分辨率的单位为PPI(Pixels Per Inch),通常叫做像素每英寸。图像分辨率一般被用于ps中,用来改变图像的清晰度。
图像分辨率的大小会影响到我们实验的进行,修改合适的分辨率可以让实验完美的进行下去。
通过python程序可以很好的调整图像的分辨率。
# -*- codeing = utf-8 -*-
# @Time : 2022/5/1 13:23
# @Author : ning
# @File : 5.1demo.py
# @software : PyCharm
import matplotlib.pyplot as plt
from PIL import Image
def produceImage(file_in, width, height, file_out):
image = Image.open(file_in)
resized_image = image.resize((width, height), Image.ANTIALIAS)
resized_image.save(file_out)
if __name__ == '__main__':
file_in = '9.jpg'
width = 256 #调整的分辨率大小
height = 256
file_out = 'demo9.png'
# 分辨率
produceImage(file_in, width, height, file_out)
更多推荐
已为社区贡献3条内容
所有评论(0)