Python程序
文章平均质量分 86
第二人生2
这个作者很懒,什么都没留下…
展开
-
文件批量重命名编号
文件批量重命名编号import os;"""文件批量重命名编号"""#参数传入要重命名的文件路径def rename(path): i =0 #读取path路径下的所有文件,返回list file_list = os.listdir(path) for files in file_list: #迭代 i=i+1 #路径和文件...原创 2020-03-05 17:39:35 · 712 阅读 · 0 评论 -
图片压缩批处理
jupyter notebook 图片压缩批处理import PIL.Image as Imageimport os#图片压缩批处理#参数为文件路径和要保存的文件的路径def compressImage(srcPath,dstPath): #读取路径下的所有的文件 for filename in os.listdir(srcPath): #目标路径不存在则...原创 2020-03-05 17:38:34 · 413 阅读 · 0 评论 -
视频压缩
jupyter notebook 视频压缩import cv2import osimport matplotlib.image as mpfrom subprocess import call"""#通过压缩图片进行压缩。压缩效果不大def compressVideo(srcPath,dstPath): for filename in os.listdir(srcPath)...原创 2020-03-05 17:35:09 · 193 阅读 · 0 评论 -
视频抓取图片
jupyter notebook 视频抓取图片"""视频抓取图片"""import os import cv2import timefrom PIL import Imagedef Video_to_image(srcPath,dstPath): cap = cv2.VideoCapture(srcPath) suc =cap.isOpened() fram...原创 2020-03-05 17:33:35 · 240 阅读 · 0 评论 -
图片合成视频
jupyter notebook 图片合成视频import globimport osimport cv2import time"""图片合成视频"""from subprocess import call#参数为文件路径,图片大小,目标路径def imgs_to_video(srcPath,size,dstPath): fps =1#帧率 #输出路径,只能输出...原创 2020-03-05 17:31:15 · 149 阅读 · 2 评论 -
图片转化为字符图
jupyter notebook 完成图片转化为字符图from PIL import ImageASCII_Char ="? " def RGB_Char(r,g,b,alpha=256): if alpha == 0: return length = len(ASCII_Char) gray = int(0.2126*r+0.7152*g+0.072...原创 2020-03-05 17:27:47 · 248 阅读 · 0 评论