Skip to content

Commit

Permalink
ImageJ exporter: save original metadata
Browse files Browse the repository at this point in the history
Fixes ome#4201.
  • Loading branch information
melissalinkert committed Aug 6, 2024
1 parent 0a895ae commit 9e9e2ed
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
import java.util.Vector;

Expand All @@ -60,6 +61,7 @@
import javax.swing.filechooser.FileFilter;

import loci.common.DataTools;
import loci.common.DebugTools;
import loci.common.services.DependencyException;
import loci.common.services.ServiceException;
import loci.common.services.ServiceFactory;
Expand Down Expand Up @@ -538,6 +540,7 @@ else if (FormatTools.isSigned(originalType)) {
}

Object info = imp.getProperty("Info");
Hashtable<String, Object> originalMetadata = new Hashtable<String, Object>();
if (info != null) {
String imageInfo = info.toString();
if (imageInfo != null) {
Expand All @@ -548,14 +551,22 @@ else if (FormatTools.isSigned(originalType)) {
String key = line.substring(0, eq).trim();
String value = line.substring(eq + 1).trim();

originalMetadata.put(key, value);

if (key.endsWith("BitsPerPixel")) {
w.setValidBitsPerPixel(Integer.parseInt(value));
break;
}
}
}
}
}
try {
service.populateOriginalMetadata(service.getOMEMetadata(store), originalMetadata);
}
catch (ServiceException e) {
IJ.log("Could not populate original metadata");
IJ.log(DebugTools.getStackTrace(e));
}

// NB: Animation rate code copied from ij.plugin.Animator#doOptions().
final int rate;
Expand Down

0 comments on commit 9e9e2ed

Please sign in to comment.