Metadata batch export

Is there a way to script a batch export that will list in a table:

  1. Image name
  2. Image Magnification
  3. Image Resolution / or pixel width
  4. Image Width
  5. Image Height

Thank you

This script will print the information (or write to it a file with a bit of modification):

def metadata = []
def delim = '\t'
for (entry in getProject().getImageList()) {
    def imageData = entry.readImageData()
    def server = imageData.getServer()
    metadata << String.join(delim,
        [entry.getImageName(),
        server.getMetadata().getMagnification(),
        server.getPixelCalibration().getAveragedPixelSize(),
        server.getWidth(),
        server.getHeight()] as String[]
        )
}

def output = String.join(System.lineSeparator, metadata)
print output

// To write to a file, use something like this
// new File('/path/to/file.txt').text = output
2 Likes

Thank you, much appreciated

1 Like

Hi, I’m trying to do similar but can’t get it to work. I’d like to output the file name and a metadata entry called “DAB Threshold”. It won’t run if an image isn’t open and with the image open it gets the data but just repeats it rather than fetching the data for the next image. Help much appreciated :slight_smile:

list = []
for (entry in getProject().getImageList()) {
    list << String.join('\t', 
    [getProjectEntry().getImageName(),getProjectEntry().getMetadataValue("DAB Threshold")]
    )
    }
def output = String.join(System.lineSeparator, list)
print output

/*OUTPUT
RUN: ERROR: NullPointerException at line 4: Cannot invoke method getImageName() on null object
RUN WITH IMAGE OPEN: 
INFO: 1M03.mrxs	0.6
1M03.mrxs	0.6
1M03.mrxs	0.6
1M03.mrxs	0.6
1M03.mrxs	0.6
1M03.mrxs	0.6
1M03.mrxs	0.6

I haven’t tested your script to see how it works, but at first glance it looks like

[getProjectEntry().getImageName(),getProjectEntry().getMetadataValue("DAB Threshold")]

should be

[entry.getImageName(),entry.getMetadataValue("DAB Threshold")]
1 Like

Lovely, thanks Melvin! :slight_smile:

1 Like