Skip to content

Commit

Permalink
Merge branch 'ebremer:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
ebremer authored May 23, 2023
2 parents 1ab584c + ad11896 commit 125d357
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 16 deletions.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Hatch 3.0.1
# Hatch 3.0.2

This tool converts the largest image in a VSI, SVS, or TIF image into a new TIFF image with a freshly created image pyramid with each scaling 1/2 dimensions each scale.

Expand All @@ -10,6 +10,17 @@ Features:

3) image pyramid is re-created from original image

Build with:

Jar version
```
mvn -Phatchjar clean package
```
Native-image version (requires fully configured Graalvm native-image environment)
```
mvn -Phatch clean package
```

Usage:
```
hatch -src <src> -dest <dest>
Expand Down
2 changes: 1 addition & 1 deletion dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>edu.stonybrook.bmi</groupId>
<artifactId>hatch</artifactId>
<version>3.0.1</version>
<version>3.0.2</version>
<build>
<resources>
<resource>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>edu.stonybrook.bmi</groupId>
<artifactId>hatch</artifactId>
<version>3.0.1</version>
<version>3.0.2</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
25 changes: 15 additions & 10 deletions src/main/java/edu/stonybrook/bmi/hatch/Hatch.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.beust.jcommander.JCommander;
import com.beust.jcommander.ParameterException;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
Expand All @@ -19,7 +20,7 @@
* @author erich
*/
public class Hatch {
public static String software = "hatch 3.0.1 by Wing-n-Beak";
public static String software = "hatch 3.0.2 by Wing-n-Beak";
private static final String[] ext = new String[] {".vsi", ".svs", ".tif"};
public static final String HELP = Hatch.software+"\n"+
"""
Expand Down Expand Up @@ -47,15 +48,14 @@ private static void Traverse(HatchParameters params) {
String frag = s.relativize(f).toString();
frag = frag.substring(0,frag.length()-4)+".tif";
Path t = Path.of(d.toString(), frag);
t.toFile().getParentFile().mkdirs();
if (!t.toFile().exists()) {
System.out.println("PROCESSING FILE --> "+f);
engine.submit(new FileProcessor(params, f.toString(), t.toString()));
engine.submit(new FileProcessor(params, f, t));
} else if (t.toFile().length()==0) {
System.out.println("ZERO LENGTH FILE --> "+f);
t.toFile().delete();
System.out.println("RE-PROCESSING FILE --> "+f);
engine.submit(new FileProcessor(params, f.toString(), t.toString()));
engine.submit(new FileProcessor(params, f, t));
}
});
} catch (IOException ex) {
Expand Down Expand Up @@ -124,18 +124,23 @@ public static void main(String[] args) {

class FileProcessor implements Callable<String> {
private final HatchParameters params;
private final String src;
private final String dest;
private final File src;
private final File dest;

public FileProcessor(HatchParameters params, String src, String dest) {
public FileProcessor(HatchParameters params, Path src, Path dest) {
this.params = params;
this.src = src;
this.dest = dest;
this.src = src.toFile();
this.dest = dest.toFile();
}

@Override
public String call() {
try (X2TIF v2t = new X2TIF(params, src, dest)) {
if (dest.exists()) {
dest.delete();
} else {
dest.getParentFile().mkdirs();
}
try (X2TIF v2t = new X2TIF(params, src.toString(), dest.toString())) {
v2t.Execute();
} catch (Exception ex) {
System.out.println("FILE PROCESSOR ERROR --> "+src+" "+dest+" "+ex.toString());
Expand Down
1 change: 1 addition & 0 deletions src/main/java/edu/stonybrook/bmi/hatch/HatchWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public void nextImage() throws IOException {
@Override
public void close() {
try (ros; writer) {
ros.flush();
System.out.println("closing Writer....");
} catch (IOException ex) {
System.out.println("HatchWriter : "+ex);
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/edu/stonybrook/bmi/hatch/X2TIF.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,6 @@ public X2TIF(HatchParameters params, String src, String dest) {
System.exit(0);
}
File fdest = new File(outputFile);
if (fdest.exists()) {
fdest.delete();
}
int size = Math.max(width, height);
int ss = (int) Math.ceil(Math.log(size)/Math.log(2));
int tiless = (int) Math.ceil(Math.log(tileSizeX)/Math.log(2));
Expand All @@ -159,9 +156,11 @@ public X2TIF(HatchParameters params, String src, String dest) {
meta.setPixelsSizeZ(new PositiveInteger(1), 0);
meta.setPixelsSizeC(new PositiveInteger(3), 0);
meta.setPixelsSizeT(new PositiveInteger(1), 0);
System.out.println("SRC : "+src+" dest: "+fdest);
} catch (DependencyException | ServiceException | FormatException | IOException ex) {
Logger.getLogger(X2TIF.class.getName()).log(Level.SEVERE, null, ex);
}

}

private int MaxImage(FormatReader reader) {
Expand Down

0 comments on commit 125d357

Please sign in to comment.