Batch > macro output is not the same as running as script


I was testing the command Process > Batch > Macro and realized that the output jpeg image is different from the one I get if I run exactly the same code from a script.

I use as test data the sample image Neuron (5 channels) slightly edited. I removed the last two channels (keeping the first 3) and save the image to disk: Rat_Hippocampal_Neuron.tif (1.5 MB)

then I opened the image and run the ijm script:

run("Split Channels");
run("Merge Channels...", "c5=C1-mainImage c6=C2-mainImage c7=C3-mainImage keep");
run("Images to Stack", "name=Stack title=[] use");
run("Make Montage...", "columns=4 rows=1 scale=0.50");

The result was an image named “Montage” that I manually saved as jpeg with File > Save As > Jpeg...

bellow is the resulting image:

Then I try the same macro through Process > Batch > Macro

and this was the result:

I tested in other images and the result was always different when comparing both methods (script vs Batch > Macro). It seems like ImageJ somehow stretches the histogram before saving when running the Batch > Macro.

Is this an error in ImageJ/Fiji or is it an option that I have somewhere that I’m not aware of?

Just a final note, I have an old linux version of Fiji (not updated during the last year) that outputs two equal images in both methods (as it should).