-
Notifications
You must be signed in to change notification settings - Fork 2
/
_DKR_Resize_Batch.ijm
64 lines (43 loc) · 1.56 KB
/
_DKR_Resize_Batch.ijm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// created by Dan Rozelle 20110324
//used to create a similarly scaled montage for each image in a file
//this will only work with flat composite images (multi channel, single slice)
macro "go [q]"{
setBatchMode(true);
if(nImages>0) exit ("close all images before proceeding");
if(isOpen("Results")){
selectWindow("Results");
run("Close");
}
if(isOpen("Log")){
selectWindow("Log");
run("Close");
}
/**********************************************************/
Dialog.create("Select Options");
Dialog.addNumber("Width in Pixels", 3000);
Dialog.show();
newWidth=Dialog.getNumber();
/**********************************************************/
//find the source images
dir1 = getDirectory("Choose source directory");
if (dir1=="")
exit("No directory available");
parent = File.getParent(dir1);
//create an array with image names
list = getFileList(dir1);
//starting with the first image, we increment through each image, checking the aspect ratio and resize
for(i=0; i<list.length; i++){
open(dir1+list[i]);
selectWindow(list[i]);
run("Select None");
getDimensions(width, height, channels, slices, frames);
newHeight= (width*newWidth)/height;
run("Size...", "width="+newWidth+" height="+newHeight+" depth="+channels+" constrain average interpolation=Bilinear");
//selectWindow(list[i]);
saveAs("Tiff", dir1+list[i]+"_"+newWidth+"px.tif");
//close the window after returning from function
//selectWindow(list[i]+"_"+newWidth+"px.tif");
close();
}
print("done");
}