Skip to content

Commit 5a2d47f

Browse files
committed
2025.01.26 (1.54n6; Exec macro function)
1 parent 63544da commit 5a2d47f

File tree

7 files changed

+45
-14
lines changed

7 files changed

+45
-14
lines changed

functions.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4604,7 +4604,7 @@ <h1>Built-in Macro Functions</h1>
46044604
<br>
46054605
<a name="setOption_SetIJMenuBar"></a>
46064606
<b>setOption("SetIJMenuBar", boolean)</b><br>
4607-
Set the ImageJ menu bar on image window activation on Macs.
4607+
On Macs, show the ImageJ menu bar on image window activation.
46084608
Requires 1.54m.
46094609
<br>
46104610
<a name="setOption_Show_All"></a>
@@ -5483,7 +5483,7 @@ <h1>Built-in Macro Functions</h1>
54835483

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

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

54885488
</body>
54895489
</html>

ij/ImageJ.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public class ImageJ extends Frame implements ActionListener,
7979

8080
/** Plugins should call IJ.getVersion() or IJ.getFullVersion() to get the version string. */
8181
public static final String VERSION = "1.54n";
82-
public static final String BUILD = "4";
82+
public static final String BUILD = "6";
8383
public static Color backgroundColor = new Color(237,237,237);
8484
/** SansSerif, 12-point, plain font. */
8585
public static final Font SansSerif12 = new Font("SansSerif", Font.PLAIN, 12);

ij/Prefs.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public class Prefs {
166166
public static boolean autoRunExamples = true;
167167
/** Ignore stack positions when displaying points. */
168168
public static boolean showAllPoints;
169-
/** Set ImageJ menu bar on image window activation on Macs. */
169+
/** Show ImageJ menu bar on image window activation on Macs. */
170170
public static boolean setIJMenuBar = IJ.isMacOSX();
171171
/** "ImageJ" window is always on top. */
172172
public static boolean alwaysOnTop;

ij/macro/Functions.java

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5157,6 +5157,25 @@ String doExt() {
51575157
return desc.dispatch(this);
51585158
}
51595159

5160+
void handleProcessBuffers(InputStream... streams){
5161+
for (int i = 0; i < streams.length; i++) {
5162+
final InputStream is = streams[i];
5163+
new Thread(new Runnable(){
5164+
@Override
5165+
public void run(){
5166+
try {
5167+
BufferedReader br = new BufferedReader(new InputStreamReader(is));
5168+
while (br.readLine() != null)
5169+
{}
5170+
} catch (IOException ioe)
5171+
{
5172+
ioe.printStackTrace();
5173+
}
5174+
}
5175+
}).start();
5176+
}
5177+
}
5178+
51605179
String exec() {
51615180
String[] cmd;
51625181
StringBuffer sb = new StringBuffer(256);
@@ -5191,14 +5210,20 @@ String exec() {
51915210
Process p = Runtime.getRuntime().exec(cmd);
51925211
boolean returnImmediately = openingDoc || !waitForCompletion;
51935212
waitForCompletion = true;
5194-
if (returnImmediately)
5213+
if (returnImmediately){
5214+
handleProcessBuffers(p.getInputStream(), p.getErrorStream()); // empty both buffers
51955215
return null;
5196-
reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
5216+
} else {
5217+
handleProcessBuffers(p.getErrorStream()); // empty only unused ErrorStream buffer
5218+
}
5219+
reader = new BufferedReader(new InputStreamReader(p.getInputStream())); // notice that this function will discard all process error output
51975220
String line; int count=1;
51985221
while ((line=reader.readLine())!=null) {
51995222
sb.append(line+"\n");
5200-
if (count++==1&&line.startsWith("Microsoft Windows"))
5201-
break; // user probably ran 'cmd' without /c option
5223+
if (count++==1&&line.startsWith("Microsoft Windows")){
5224+
handleProcessBuffers(p.getInputStream()); // must empty the InputStream buffer anyway
5225+
break; // user probably ran 'cmd' without /c option
5226+
}
52025227
}
52035228
} catch (Exception e) {
52045229
sb.append(e.getMessage()+"\n");

ij/plugin/StackWriter.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,12 @@ else if (format.equals("text image"))
141141
}
142142
if (label==null)
143143
path = directory+name+digits+extension;
144-
else
145-
path = directory+label+extension;
144+
else {
145+
if (label.toLowerCase().endsWith(".tiff") && ".tif".equals(extension))
146+
path = directory+label;
147+
else
148+
path = directory+label+extension;
149+
}
146150
if (i==1) {
147151
File f = new File(path);
148152
if (f.exists()) {
@@ -261,4 +265,3 @@ String getDigits(int n) {
261265
}
262266

263267
}
264-

ij/process/LUT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public String toString() {
108108
+Colors.colorToString(new Color(getRGB(255)))+", min="+IJ.d2s(min,4)+", max="+IJ.d2s(max,4);
109109
}
110110

111-
/** Returns 'true' if the LUTs of these two images differ. */
111+
/** Returns 'true' if the LUTs of the two images differ. */
112112
public static boolean LutsDiffer(ImagePlus imp1, ImagePlus imp2) {
113113
if (!imp1.isComposite() || !imp2.isComposite())
114114
return false;

release-notes.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66
<body>
77

88

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

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

0 commit comments

Comments
 (0)