aboutsummaryrefslogtreecommitdiff
path: root/src/conversion/czi/convertJxrs.py
diff options
context:
space:
mode:
authorcjd242018-02-26 00:36:01 +0000
committercjd242018-02-26 00:36:01 +0000
commitb984807d99328ff9d5813d8b9305cc92f515645e (patch)
tree67cac4df7a2666a02381e0f1ba489a2b46bcdc71 /src/conversion/czi/convertJxrs.py
parentRevert "Revert "Merge branch 'trh/error-middleware' into 'master'"" (diff)
downloadmedicine-b984807d99328ff9d5813d8b9305cc92f515645e.tar.gz
medicine-b984807d99328ff9d5813d8b9305cc92f515645e.zip

Adding script to get Jxr conversion lib, and all my current C code for extracting and converting czi files to normal things

Diffstat (limited to 'src/conversion/czi/convertJxrs.py')
-rw-r--r--src/conversion/czi/convertJxrs.py38
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 ===========")