from wand.image import Image as wima from wand.color import Color import os from concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor, as_completed, wait def wmf2png(old_src): """ 1.将公式wmf格式转化为png图片 :param old_src: :return: """ with wima(filename=old_src, resolution=300, background=Color('rgba( 0, 0, 0, 0.0)'), format='png') as img: # newfilename = os.path.join(base_dir, fname[:-3]+"png") # img.convert() img.save(filename=os.path.splitext(old_src)[0] + ".png") def svg2png(old_src): """svg转png""" with wima(filename=old_src, resolution=200, background=Color('rgba( 0, 0, 0, 0.0)'), format='png') as img: newfilename = os.path.splitext(old_src)[0] + ".png" img.save(filename=newfilename) return img.size, newfilename