setting foreground color in batch (headless) mode

Posted by grimper on
URL: http://imagej.273.s1.nabble.com/setting-foreground-color-in-batch-headless-mode-tp5008374.html

Hi everyone,

I am trying to get ImageJ draw/fill some pattern in headless mode (i.e. batch mode called from command line). However, it seems that the macro command " setForegroundColor(r,g,b);" is not working correctly.
For example, using a very simple macro "draw.txt":
-------------------------
newImage("draw", "RGB ramp", 100, 100, 1);
setForegroundColor(255, 255, 255);
arrowX=30;
arrowY1=10;
arrowY2=30;
makePolygon(arrowX-10,arrowY1,arrowX+10, arrowY1,arrowX, arrowY2);
run("Fill", "slice");
setForegroundColor(0, 0, 0);
arrowX=60;
arrowY1=10;
arrowY2=30;
makePolygon(arrowX-10,arrowY1,arrowX+10, arrowY1,arrowX, arrowY2);
run("Fill", "slice");
saveAs("jpeg", "draw.jpg");
--------------------

When it is call from the command line:
java -jar /home/grimper/.imagej/ij.jar -ijpath /home/grimper/.imagej/ -batch draw

It failed to change the foreground color, it always fills the polygon in black.
(but when launched in -macro mode, it works correctly)

Any idea how to fix it ?

Thanks,

Zong