Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
A possible parallel solution using imageio: from imageio import imwrite from multiprocessing import Pool from numpy import load from pathlib import Path def npy2png(npyFile): imwrite(...
Answer
#1: Initial revision
A possible parallel solution using `imageio`: ``` from imageio import imwrite from multiprocessing import Pool from numpy import load from pathlib import Path def npy2png(npyFile): imwrite(npyFile.stem + '.png', load(npyFile)) rootPath = Path('/path/to/Main_dir') if __name__ == '__main__': with Pool(processes=8) as pool: pool.map(npy2png, rootPath.glob('*npy')) ``` Additional arguments can be passed to `imwrite`; in the case of the PNG format, execute ``` import imageio imageio.help(name='png') ``` to know which ones are available.