ImagePlus, duplicate() does not cropped


I always use duplicate() method for cropping image by ROIs.
The code seems to have changed in recent versions, and it may not be cropped.
So, I read ImagePlus duplicate method code and I found changing this method…
Is it only me that the impact is large?
…old version dose not have crop() method, so I would like to know when it changed.


public ImagePlus duplicate() {
 return (new Duplicator()).run(this);


public ImagePlus duplicate() {
		Roi roi = getRoi();
		ImagePlus imp2 =(new Duplicator()).run(this);
		return imp2;
public ImagePlus crop() {
		return (new Duplicator()).crop(this);

Interesting, I need to check some of my own code isn’t affected by this…

It looks like duplicateAll was introduced here, but this was removed and became behavior for duplicate in December here.

In addition!

crop() method can not crop all stack image,just current slice only,
Anyway, this change has a big impact, so please keep the previous behavior as well.

I must change duplication point to “ImagePlus imp2 =(new Duplicator()).run(ImagePlus);”
…I feel like something meaningless

Thanks for reporting this. I also noticed that a plugin behaved differently between an IDE and a Fiji install. I’m pretty sure it’s related to this issue.

In ImageJ 1.52n and later, the ImagePlus.duplicate() method does not crop. Instead, use

imp2 = imp.crop("stack") (requires 1.52o14 daily build)


imp2 = new Duplicator().run(imp)

Hi Wayne,

Thank you for your replay and add the method.
However, I am going to change duplicate() to Duplicator().run() or another way to be flexible.


Following that, one question about the javadoc, is the corresponding ImageJ release version indicated somewhere ?

1 Like

The JavaDocs for the daily build are not available but the 1.52o14 commit has the source code for the new ImagePlus.crop(options) method:

Here are some examples (generated by the recorder):

imp2 = imp.duplicate(); //duplicate the image or entire stack
imp2 = imp.crop();  // crop the image or stack slice
imp2 = imp.crop("slice");  // crop the image or stack slice
imp2 = imp.crop("stack"); // crop the image or entire stack
imp2 = imp.crop("1-10"); // crop a range of stack slices