Saving animated gif with custom fps

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"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?


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("");;, "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: