Skip to content

Instantly share code, notes, and snippets.

@T4mmi
Last active March 27, 2023 17:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save T4mmi/6c37de32adcd67d46e3d1e7b7b966ba1 to your computer and use it in GitHub Desktop.
Save T4mmi/6c37de32adcd67d46e3d1e7b7b966ba1 to your computer and use it in GitHub Desktop.
Batch rotate image AND ImageJ markers
macro "Batch rotate images and annotations" {
/* Read images in a chosen directory and rotate them along
with the annotations (points) and store them inplace */
source_dir = getDirectory("Choose an input Directory "); // window to select the input directory
dest_dir = getDirectory("Choose an output Directory "); // window to select the output directory
list = getFileList(source_dir); // list files in it
angle = getNumber("choose the clockwise rotation angle", 90);
setBatchMode(true); // activate batch process
for (i=0; i<list.length; i++) { // loop over files
showProgress(i, list.length); // update progressbar
file_name = list[i];
if (endsWith(file_name, ".tif")) {
file_path = source_dir + file_name;
new_path = dest_dir + file_name;
open(file_path); // open the current image
run("Rotate...", "rotate angle=" + angle);
run("Rotate... ", "angle=" + angle + " grid=1 interpolation=None");
save(new_path);
close();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment