setting foreground color in batch (headless) mode

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

setting foreground color in batch (headless) mode

grimper
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
Reply | Threaded
Open this post in threaded view
|

Re: setting foreground color in batch (headless) mode

Rasband, Wayne (NIH/NIMH) [E]
On Jun 23, 2014, at 10:30 AM, grimper wrote:

> 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.

The latest ImageJ daily build (1.49c19) fixes a bug that caused the setForegroundColor() macro function to not work in headless mode, for example when a macro was called from the command line using the -batch option.

-wayne

> 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
>
>
>
>
> --
> View this message in context: http://imagej.1557.x6.nabble.com/setting-foreground-color-in-batch-headless-mode-tp5008374.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: setting foreground color in batch (headless) mode

grimper
Fantastic !!

Thank you Wayne for such a quick fix.

Best regards,

Zong