From 3af993b19c18182c2c10c9263acc5cd957861b3f Mon Sep 17 00:00:00 2001
From: Christian Kento Rasmussen <christian.kento@gmail.com>
Date: Mon, 10 Jun 2024 14:35:57 +0200
Subject: [PATCH] Fixed error when converting zarr files

---
 qim3d/io/convert.py | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/qim3d/io/convert.py b/qim3d/io/convert.py
index aa803d8b..f1dd14e8 100644
--- a/qim3d/io/convert.py
+++ b/qim3d/io/convert.py
@@ -23,21 +23,23 @@ class Convert:
     def convert(self, input_path, output_path):
         # Stringify path in case it is not already a string
         input_path = stringify_path(input_path)
+        input_ext = os.path.splitext(input_path)[1]
+        output_ext = os.path.splitext(output_path)[1]
         output_path = stringify_path(output_path)
 
-        if os.path.isfile(input_path):
-            input_ext = os.path.splitext(input_path)[1]
-            output_ext = os.path.splitext(output_path)[1]
+        if os.path.isfile(input_path):  
             match input_ext, output_ext:
                 case (".tif", ".zarr"):
                     return self.convert_tif_to_zarr(input_path, output_path)
-                case (".zarr", ".tif"):
-                    return self.convert_zarr_to_tif(input_path, output_path)
                 case _:
                     raise ValueError("Unsupported file format")
         # Load a directory
         elif os.path.isdir(input_path):
-            raise ValueError("Unsupported file format")
+            match input_ext, output_ext:
+                case (".zarr", ".tif"):
+                    return self.convert_zarr_to_tif(input_path, output_path)
+                case _:
+                    raise ValueError("Unsupported file format")
         # Fail
         else:
             # Find the closest matching path to warn the user
-- 
GitLab