Saving animated gif with custom fps

Hi,
I’m trying to save an animated gif by calling the Gif Stack Writer from my Java code, but either the class needs a windowed instance of IJ, or, when I use IJ.run("Animated Gif … "), I get the following error:

“Unrecognized Command: Animated Gif…”

I am sure the spelling is correct.
It happens very often for different commands that the command is best suited for Fiji GUI and not for code calls, but I never find a clear answer.

How to solve this?

Thanks.

Here a solution (change the path, options and disable show() if you do not want to open the image!):

import ij.IJ;
import ij.ImagePlus;
import ij.plugin.PlugIn;

public class My_Plugin implements PlugIn {

	public void run(String arg) {
		ImagePlus imp = IJ.openImage("http://wsr.imagej.net/images/mri-stack.zip");
		imp.show();
		IJ.run(imp, "Animation Options...", "speed=1 first=1 last=27");
		IJ.saveAs(imp, "Gif", "C:/MyFolder/mri-stack.gif");
	}
}

Works great, thanks.
I don’t even need to show the image :smiley: