How to run external plugin in my plugin

I’ve got a simple question, im developing my plugins for imagej. Is it possible to run plugin in some certain time when my plugin is running? For example after pressing some button from dialogbox.
If it is, please explain me how to do that.

I would like to execute plugin image>stacks>reslice from my plugin
Thanks in advance

To get the right command just use the macro recorder of ImageJ (set to Java) when executing the reslice action, see:

ImageJ User Guide - IJ 1.46r | Plugins Menu

1 Like

Thanks for quick answer, that works really well.
I have another question now, after my plugin executes that another plugin, how do I set my plugin to later work on new generated image instead of my old one?

If a new image is created you can always use the ImageJ API, see:

Here you find a lot of methods to open, select, etc. images.

Also use the API examples as a start:


There are also some good books for ImageJ available.

1 Like

I’ve been through some of the documentation, but cannot find good solution to do what I wrote,
I mean after my plugin executes “external plugin” and new image is created from it, how do I select the new image to have next operations be performed on it? Could you possibly tip me the best solution?


1 Like

Just use e.g.…

or use the WindowManager:

Have a look at the API.

1 Like

Thank you so much dude! Really appreciate the help

Hey, could u possibly tell me how to “not show” new image after using for example method to rotate the image stack?

Here is one simple example:

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("");, "Rotate... ", "angle=45.10 grid=1 interpolation=Bilinear");;//Show image

You simply operate on the ImagePlus object or copies of it if necessary ( opens the final image).

There is also a Rotator class which can be used directly. But with the Java recorder you aim and shoot.

For a stack the recorder gives (with the mri-stack example and default options):

imp = IJ.openImage("");, "Rotate... ", "angle=45.10 grid=1 interpolation=Bilinear stack");
1 Like

Thanks for your help again ! Really appreciate that.
I have last question, lets say i have 100x100 imagestack with 100 slices.
In code im creating new hyperstack with size 102x102 with 100 slices.
How can I copy roi with pixel values for all the slices from first image to the new one, placing roi at (1,1) instead of (0,0) position, so I would have edges with empty values?

Why not simply use the resize canvas action, see:…

You can record the Java command in the macro recorder.


Thanks again, huge respect for you bro