python检测图片真实格式并修改
2019-12-22 本文已影响0人
PsAlex
import imghdr
from PIL import Image
import os
file_path=os.getcwd()
for x in os.walk(file_path):
for y in x[2]:
if imghdr.what(y):
os.rename(y,y.split('.')[0]+'.'+imghdr.what(y))