新聞中心
這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
創(chuàng)新互聯(lián)Python教程:python旋轉(zhuǎn)圖片和壓縮像素的方法
說明

1、使用rotate旋轉(zhuǎn)方向時(shí),需要注意添加expand=True參數(shù),否則會(huì)出現(xiàn)黑邊。
2、手機(jī)的照片像素太高,有些需要壓縮,以確保最終pdf的大小適中。
實(shí)例
img = Image.open(path) if img.size[0] > img.size[1]: im_rotate = img.rotate(90, expand=True) size = (int(im_rotate.size[0] / 3), int(im_rotate.size[1] / 3)) im_rotate = im_rotate.resize(size) im_rotate.save(savepath, quality=95) else: size = (int(img.size[0] / 3), int(img.size[1] / 3)) img = img.resize(size) img.save(savepath, quality=95)
以上就是python旋轉(zhuǎn)圖片和壓縮像素的方法,希望對(duì)大家有所幫助。更多Python學(xué)習(xí)指路:創(chuàng)新互聯(lián)python教程
本文教程操作環(huán)境:windows7系統(tǒng)、Python 3.9.1,DELL G3電腦。
本文題目:創(chuàng)新互聯(lián)Python教程:python旋轉(zhuǎn)圖片和壓縮像素的方法
URL鏈接:http://m.fisionsoft.com.cn/article/djppehj.html


咨詢
建站咨詢
