Crop images with different sizes always from center

Hey there!

I have a bunch of images with different sizes. I want to crop all of them to the same size of 10000x10000 pixels around the center of the image.

I have the following idea:

  • measure centroid (to find the center coordinates of the image)
  • specify a 10000x10000 rectangle
  • crop
  • save as .tif

So how can I set up a macro which always makes the rectangle from the center of the image? (The center coordinates changing from image to image)

I appreciate any help.
Thank you

Hey Benjamin. Something like the following macro should work:

h = getHeight();
w = getWidth();
makeRectangle(w/2-size/2, h/2-size/2, size, size);

Regards, David

Thank you David, this works brilliant!

Regards, Benjamin