diff options
| author | Tom Harley | 2018-03-07 16:00:54 +0000 |
|---|---|---|
| committer | Tom Harley | 2018-03-07 16:00:54 +0000 |
| commit | e338c8ce35f22812ae1de5303a06edde166ba8cf (patch) | |
| tree | e80a4f060816b57a60357fb832bb7bcbeac78b0a /src/conversion/czi/convertJxrs.py | |
| parent | Merge remote-tracking branch 'origin/testing-middleware' into development (diff) | |
| parent | Adding support for the protocol's supported_views thing and laid base work fo... (diff) | |
| download | medicine-e338c8ce35f22812ae1de5303a06edde166ba8cf.tar.gz medicine-e338c8ce35f22812ae1de5303a06edde166ba8cf.zip | |
Merge branch ‘cjd24/conversion’ into development
Diffstat (limited to 'src/conversion/czi/convertJxrs.py')
| -rw-r--r-- | src/conversion/czi/convertJxrs.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/conversion/czi/convertJxrs.py b/src/conversion/czi/convertJxrs.py new file mode 100644 index 0000000..d19a59a --- /dev/null +++ b/src/conversion/czi/convertJxrs.py @@ -0,0 +1,38 @@ +from concurrent.futures import ThreadPoolExecutor +from subprocess import check_call +from glob import glob +from sys import argv + +totalFiles = 0 +coutner = 0 + + +def convertjxrs(filename): + global counter + global totalFiles + asTif = filename.rsplit('.',1)[0] + ".tif" + check_call(['./JxrDecApp', "-i", filename, "-o", asTif]) + check_call(['convert', asTif, filename.rsplit('.',1)[0] + ".png"]) + check_call(['rm', filename, asTif]) + counter += 1 + print (f"> Processed File: {counter}/{totalFiles} : {filename} --> {filename.rsplit('.',1)[0]}.png") + + +if __name__ == "__main__": + + if (len(argv) != 2): + print("\nMissing Argument!\n\nUsage:\npython3 convertJxrs.py <DirectoryContainingJxrs>") + exit(0) + else: + print("=========== BEGIN JXR CONVERSION ===========") + print ('Files Dir: ' + argv[1] + '\n') + + filenames = glob(argv[1] + 'data-*.jxr') + counter = 0 + totalFiles = len(filenames) + + pool = ThreadPoolExecutor(5) + for f in pool.map(convertjxrs, filenames): + pass + pool.shutdown(True) + print("=========== FINISH JXR CONVERSION ===========") |
