Files
004_comission/vinniesniper-54816/task1/_lab/007-train-beach-test/posdata.1/_BMP2JPG.py
louiscklaw b3cc8e8323 update,
2025-01-31 22:57:47 +08:00

17 lines
394 B
Python

import os
from PIL import Image
json_dir = "./"
label_names = os.listdir(json_dir)
label_dir = []
for filename in label_names:
label_dir.append(os.path.join(json_dir,filename))
for i,filename in enumerate(label_dir):
im = Image.open(filename) # open ppm file
newname = label_names[i].split('.')[0] + '.jpg' # new name for png file
im.save(os.path.join(json_dir,newname))