diff options
| author | Tom Harley | 2018-04-23 01:53:39 +0100 |
|---|---|---|
| committer | Tom Harley | 2018-04-23 01:53:39 +0100 |
| commit | de38a80b0b69a2655e5a2f30cf207aab63379d69 (patch) | |
| tree | 9b907384e015ad6751ecc74ab77ceb8d271ff7cf /src/conversion/czi/convertJxrs.py | |
| parent | Fix tests and add handy server scripts (diff) | |
| parent | fixing stuff in the csv conversion and adding supported views capability (diff) | |
| download | medicine-de38a80b0b69a2655e5a2f30cf207aab63379d69.tar.gz medicine-de38a80b0b69a2655e5a2f30cf207aab63379d69.zip | |
Merge branch ‘cjd24/conversion’ into trh/gets
Diffstat (limited to 'src/conversion/czi/convertJxrs.py')
| -rw-r--r-- | src/conversion/czi/convertJxrs.py | 47 |
1 files changed, 27 insertions, 20 deletions
diff --git a/src/conversion/czi/convertJxrs.py b/src/conversion/czi/convertJxrs.py index d19a59a..f4b897f 100644 --- a/src/conversion/czi/convertJxrs.py +++ b/src/conversion/czi/convertJxrs.py @@ -8,14 +8,21 @@ 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") + global counter + global totalFiles + try: + 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 + except Exception as help: + print ("Processing Failed. Probably couldn't find decoder due to invalid system environment path, check this before debugging."); + print ("Actual error was:"); + print (help); + exit(0); + + print (f"> Processed File: {counter}/{totalFiles} : {filename} --> {filename.rsplit('.',1)[0]}.png") if __name__ == "__main__": @@ -24,15 +31,15 @@ if __name__ == "__main__": 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 ===========") + 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 ===========") |
