#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
from wand.image import Image
from struct import *

def pdfToPng():
path = "/home/siyin/素材库各20例/"
listdir = os.listdir(path)
print listdir
for dir in listdir:
basePath = path + dir + "/"
savePath = "/home/siyin/素材库各20例(png)/" + dir + "/"
if os.path.exists(savePath) == False:
os.mkdir(savePath)
fileList = os.listdir(basePath)
for file in fileList:
filePath = basePath + file
print filePath
newFileName = file.split(".")[0]
with Image(filename=filePath) as img:
if(file.split(".")[1] == "png" ):
img.save(filename=savePath+file)
else:
img.save(filename=savePath + newFileName + ".png" )
os.remove(filePath)
if __name__ == "__main__":
pdfToPng()

相关文章:

  • 2022-01-09
  • 2021-11-17
  • 2021-11-26
  • 2022-02-07
  • 2022-12-23
  • 2022-12-23
  • 2021-06-23
猜你喜欢
  • 2021-06-03
  • 2021-11-17
  • 2021-12-07
  • 2021-07-14
  • 2022-12-23
  • 2021-07-07
相关资源
相似解决方案