Skip to content

Commit

Permalink
2025.01.26 (1.54n6; Exec macro function)
Browse files Browse the repository at this point in the history
  • Loading branch information
rasband committed Jan 26, 2025
1 parent 63544da commit 5a2d47f
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 14 deletions.
4 changes: 2 additions & 2 deletions functions.html
Original file line number Diff line number Diff line change
Expand Up @@ -4604,7 +4604,7 @@ <h1>Built-in Macro Functions</h1>
<br>
<a name="setOption_SetIJMenuBar"></a>
<b>setOption("SetIJMenuBar", boolean)</b><br>
Set the ImageJ menu bar on image window activation on Macs.
On Macs, show the ImageJ menu bar on image window activation.
Requires 1.54m.
<br>
<a name="setOption_Show_All"></a>
Expand Down Expand Up @@ -5483,7 +5483,7 @@ <h1>Built-in Macro Functions</h1>

<p class=navbar> <a href="#Top">top</a> | <a href="https://imagej.net/ij/index.html">home</a></p>

<small>Last updated 2024-06-17</small>
<small>Last updated 2025-01-18</small>

</body>
</html>
2 changes: 1 addition & 1 deletion ij/ImageJ.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public class ImageJ extends Frame implements ActionListener,

/** Plugins should call IJ.getVersion() or IJ.getFullVersion() to get the version string. */
public static final String VERSION = "1.54n";
public static final String BUILD = "4";
public static final String BUILD = "6";
public static Color backgroundColor = new Color(237,237,237);
/** SansSerif, 12-point, plain font. */
public static final Font SansSerif12 = new Font("SansSerif", Font.PLAIN, 12);
Expand Down
2 changes: 1 addition & 1 deletion ij/Prefs.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public class Prefs {
public static boolean autoRunExamples = true;
/** Ignore stack positions when displaying points. */
public static boolean showAllPoints;
/** Set ImageJ menu bar on image window activation on Macs. */
/** Show ImageJ menu bar on image window activation on Macs. */
public static boolean setIJMenuBar = IJ.isMacOSX();
/** "ImageJ" window is always on top. */
public static boolean alwaysOnTop;
Expand Down
33 changes: 29 additions & 4 deletions ij/macro/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -5157,6 +5157,25 @@ String doExt() {
return desc.dispatch(this);
}

void handleProcessBuffers(InputStream... streams){
for (int i = 0; i < streams.length; i++) {
final InputStream is = streams[i];
new Thread(new Runnable(){
@Override
public void run(){
try {
BufferedReader br = new BufferedReader(new InputStreamReader(is));
while (br.readLine() != null)
{}
} catch (IOException ioe)
{
ioe.printStackTrace();
}
}
}).start();
}
}

String exec() {
String[] cmd;
StringBuffer sb = new StringBuffer(256);
Expand Down Expand Up @@ -5191,14 +5210,20 @@ String exec() {
Process p = Runtime.getRuntime().exec(cmd);
boolean returnImmediately = openingDoc || !waitForCompletion;
waitForCompletion = true;
if (returnImmediately)
if (returnImmediately){
handleProcessBuffers(p.getInputStream(), p.getErrorStream()); // empty both buffers
return null;
reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
} else {
handleProcessBuffers(p.getErrorStream()); // empty only unused ErrorStream buffer
}
reader = new BufferedReader(new InputStreamReader(p.getInputStream())); // notice that this function will discard all process error output
String line; int count=1;
while ((line=reader.readLine())!=null) {
sb.append(line+"\n");
if (count++==1&&line.startsWith("Microsoft Windows"))
break; // user probably ran 'cmd' without /c option
if (count++==1&&line.startsWith("Microsoft Windows")){
handleProcessBuffers(p.getInputStream()); // must empty the InputStream buffer anyway
break; // user probably ran 'cmd' without /c option
}
}
} catch (Exception e) {
sb.append(e.getMessage()+"\n");
Expand Down
9 changes: 6 additions & 3 deletions ij/plugin/StackWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,12 @@ else if (format.equals("text image"))
}
if (label==null)
path = directory+name+digits+extension;
else
path = directory+label+extension;
else {
if (label.toLowerCase().endsWith(".tiff") && ".tif".equals(extension))
path = directory+label;
else
path = directory+label+extension;
}
if (i==1) {
File f = new File(path);
if (f.exists()) {
Expand Down Expand Up @@ -261,4 +265,3 @@ String getDigits(int n) {
}

}

2 changes: 1 addition & 1 deletion ij/process/LUT.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public String toString() {
+Colors.colorToString(new Color(getRGB(255)))+", min="+IJ.d2s(min,4)+", max="+IJ.d2s(max,4);
}

/** Returns 'true' if the LUTs of these two images differ. */
/** Returns 'true' if the LUTs of the two images differ. */
public static boolean LutsDiffer(ImagePlus imp1, ImagePlus imp2) {
if (!imp1.isComposite() || !imp2.isComposite())
return false;
Expand Down
7 changes: 5 additions & 2 deletions release-notes.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
<body>


<li> <u>1.54n4 17 December 2024</u>
<li> <u>1.54n6 26 January 2025</u>
<ul>
<li> Thanks to Christophe Leterrier, fixed bugs with how
the <i>Image&gt;Stacks&gt;Tools&gt;Combine</i> and
<i>Edit&gt;Selection&gt;Straighten</i> commands handle
multi-channel images.
<li> Thanks to Murilo Spineli, fixed crashes with processes
started by exec() macro function.
</ul>

<li> <u>1.54m 5 December 2024</u>
Expand All @@ -28,7 +30,8 @@
and returns commands where all words are found in either the command
name or the menu path.
<li> Thanks to 'Jerry1144', added the setOption("SetIJMenuBar",boolean)
macro function.
macro function. Determines whether the ImageJ menu bar is displayed on
image window activation on Macs.
<li> Thanks to Kenneth Sloan, added the Roi.setMinStrokeWidth(minStrokeWidth)
macro function and Java method that you can use to specify a
minimum scaled stroke width
Expand Down

0 comments on commit 5a2d47f

Please sign in to comment.