Login  Register

How to save an image in different formats

Posted by sabau daniel on Apr 26, 2016; 3:35pm
URL: http://imagej.273.s1.nabble.com/How-to-save-an-image-in-different-formats-tp5016229.html

Hello,I'm new in imagej, and i want to make a field/label with an option to save an image in jpg,tiff,jpeg .How to do that,how to implement in the following code.Thanks.
import java.io.File;

import ij.IJ;

import ij.ImagePlus;

import ij.plugin.PlugIn;

importij.process.ImageProcessor;


 
//This plugin shows the basicstructure of a code.

public class Open_Image implements PlugIn {

       public void run(String arg) { //Method Belongingto PlugIn Implementation

             

              StringmyDirector1 = IJ.getDirectory("Select SourceFolder...");        //This pluginopens the select folder window in ImageJ

              if (myDirector1==null) return;                                                                              //If not sourcefolder is selected the plugin stops here

              String[]myListSources = new File(myDirector1).list();                                        //This string contains all the filesnames in the source folder

              if (myListSources==null) return;

              IJ.log("The sourceimage folder chosen was"+myDirector1);                              //This command opens the log window andwrites on the variables on it.

             

              StringmyDirector2 = IJ.getDirectory("Select SavingFolder...");

              if (myDirector2==null) return;                                                                              //If not savingfolder is selected the plugin stops here

              IJ.log("The savingfolder chosen was"+myDirector2);

                    

              int Image;


 
              for (Image = 0; Image < myListSources.length; Image++) {

                    

                     IJ.showProgress(Image,myListSources.length);                                    //This command sets magnitude the progressbar on ImageJ

                     IJ.log((Image+1)+":"+myListSources[Image]);

                     IJ.showStatus(Image+"/"+myListSources.length);                                         //This command sets a text in theImageJ status bar

                    

                           ImagePlusmyImPlus = IJ.openImage(myDirector1+myListSources[Image]);

                           myImPlus.show();                                                                               //This commandopens a window with the corresponding ImagePlus

                           ImageProcessormyIp = myImPlus.getProcessor();

                           myImPlus.updateAndDraw();


             

              IJ.log("Completed");

       }

}


--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html