【发布时间】:2019-06-02 23:01:12
【问题描述】:
我有一个装满 ppm 图像的文件夹,我想保存它们的 png 个副本。
我该怎么做?
我尝试执行以下代码,但没有任何反应。
import cv2
import numpy as np
import glob
import sys
import os.path
from os.path import isfile,join
from PIL import Image
target_path = '/Users/lfw/test'
trg = os.listdir(target_path)
count = 0
for i in trg:
fullpath = os.path.join(target_path ,i)
if os.path.isfile(fullpath):
im = Image.open(fullpath)
im.save(str(count) + 'output.png')
count = count + 1
【问题讨论】:
标签: python image directory png ppm