From 691e8633a53f9aa05fc567135c33d1cd77000047 Mon Sep 17 00:00:00 2001 From: Stephan Preibisch Date: Fri, 11 Oct 2024 11:39:28 -0400 Subject: [PATCH] work-around for an a little bit annoying behavior in N5ImageLoader @tpietzsch ... --- .../mvrecon/fiji/plugin/resave/Resave_N5Api.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/preibisch/mvrecon/fiji/plugin/resave/Resave_N5Api.java b/src/main/java/net/preibisch/mvrecon/fiji/plugin/resave/Resave_N5Api.java index 89a803e9..1f1ca104 100644 --- a/src/main/java/net/preibisch/mvrecon/fiji/plugin/resave/Resave_N5Api.java +++ b/src/main/java/net/preibisch/mvrecon/fiji/plugin/resave/Resave_N5Api.java @@ -266,7 +266,20 @@ public static SpimData2 resaveN5( if ( format == StorageFormat.N5 && URITools.isFile( n5Params.n5URI )) // local file { - sdReduced.getSequenceDescription().setImgLoader( new N5ImageLoader( n5Params.n5URI, sdReduced.getSequenceDescription() ) ); + File f; + try + { + // might trigger Exception in thread "main" java.lang.IllegalArgumentException: URI is not absolute + f = new File( n5Params.n5URI ); + } + catch ( Exception e ) + { + f = new File( n5Params.n5URI.toString() ); + } + + // we need to init with File and not with URI, since otherwise the N5ImageLoader will trigger the exception above if this object is re-used + // this seems to not matter when opening directly from disc... + sdReduced.getSequenceDescription().setImgLoader( new N5ImageLoader( f, sdReduced.getSequenceDescription() ) ); n5Writer.close(); } else if ( format == StorageFormat.N5 ) // some cloud location