Change unit of length in a macro

Hello Everyone,

I am developing a macro to analyze batchs of TEM images.
However, some of them are in microns and others in nm.
Therefore, I would like to have all of them in nm by default, otherwise it messes with my results.
I know that such a thing is possible using image properties but I cannot quite figure out how to put it in a macro.
Does anyone have a solution?

Thank you