We're Hiring!

Bio-Format 1sc to jpg batch conversion

Historical discussions about the Bio-Formats library. Please look for and ask new questions at https://forum.image.sc/tags/bio-formats
Please note:
Historical discussions about the Bio-Formats library. Please look for and ask new questions at https://forum.image.sc/tags/bio-formats

If you are having trouble with image files, there is information about reporting bugs in the Bio-Formats documentation. Please send us the data and let us know what version of Bio-Formats you are using. For issues with your code, please provide a link to a public repository, ideally GitHub.

Bio-Format 1sc to jpg batch conversion

Postby Stocca » Sat Oct 06, 2012 1:45 pm

Hi all!
Can someone help me?
I hope I am not off-topic here but I have seen similar threads....

I have more than 4 GB of 1sc pictures (Bio-Rad), which I can open with ImageJ/Bio-Formats.
I found a super-nice macro by Melissa to converts all files in a directory to TIFF.
The problem I have is that saved tiff pictures are almost completely black
when saved with Bio-Formats Macro Extensions but OK if manually saved with ImageJ menu.

My question is:
How can this macro be changed in such a way that:
- Files are saved in jpg and not in tiff format
- The macro uses the normal ImageJ save function and not Bio-Formats exporter?

I thank you so much for your help,
Stocca

-----
Name of the Macro: batchTiffConvert.txt (http://loci.wisc.edu/bio-formats/imagej)
-----

// batchTiffConvert.txt
// Author: Melissa Linkert <melissa at glencoesoftware.com>
// Last updated: 28 March 2011
// Converts all files in a directory to TIFF using the Bio-Formats macro
// extensions. There will either be one TIFF file per plane or one TIFF file
// per input file, depending upon the value of 'oneFilePerSlice' (see below).
// By default, one TIFF file is created for each plane in each file.

oneFilePerSlice = true;

directory = getDirectory("Choose input files");
fileList = getFileList(directory);
outputDirectory = getDirectory("Choose output directory");
run("Bio-Formats Macro Extensions");
setBatchMode(true);
for (i=0; i<fileList.length; i++) {
file = directory + fileList[i];
if (oneFilePerSlice) {
Ext.setId(file);
Ext.getImageCount(imageCount);
for (image=0; image<imageCount; image++) {
Ext.openImage("", image);
outFile = outputDirectory + fileList[i] + "-" + image + ".tiff";
saveFile(outFile);
close();
}
Ext.close();
}
else {
Ext.openImagePlus(file);
outFile = outputDirectory + fileList[i] + ".tiff";
saveFile(outFile);
close();
}
}
showStatus("Finished.");
setBatchMode(false);

function saveFile(outFile) {
run("Bio-Formats Exporter", "save=[" + outFile + "] compression=Uncompressed");
}
-----
Stocca
 
Posts: 2
Joined: Sat Oct 06, 2012 1:36 pm

Re: Bio-Format 1sc to jpg batch conversion

Postby mlinkert » Sat Oct 06, 2012 9:36 pm

Hi Stocca,

My question is:
How can this macro be changed in such a way that:
- Files are saved in jpg and not in tiff format
- The macro uses the normal ImageJ save function and not Bio-Formats exporter?


Replacing both instances of ".tiff" with ".jpg" and replacing this line:

Code: Select all
run("Bio-Formats Exporter", "save=[" + outFile + "] compression=Uncompressed");


with this:

Code: Select all
saveAs("Jpeg", outFile);


should do the trick.

Regards,
-Melissa
User avatar
mlinkert
Team Member
 
Posts: 353
Joined: Fri May 29, 2009 2:12 pm
Location: Southwest Wisconsin

Re: Bio-Format 1sc to jpg batch conversion

Postby Stocca » Sun Oct 07, 2012 9:20 am

It works perfectly, :D
thank you so much!
Stocca
 
Posts: 2
Joined: Sat Oct 06, 2012 1:36 pm


Return to User Discussion [Legacy]

Who is online

Users browsing this forum: No registered users and 1 guest