Image save as TIFF: Does not include scalebar

Hi

I wrote a script to add a scalebar to all images inside a certain folder and then save those images (with scalebar) to a different folder. However, if I save as TIFF, this does not include the scalebar whereas it does when I save as PNG. Anyone have an idea why this is? I included the script below with the Save as TIFF command included as comment.

Thx!

function addScaleBar(input_path, output_path, width, height, font){

    list_files = getFileList(input_path);

    for(i = 0; i < list_files.length; i++){
    	setBatchMode(true);
    	
        file = list_files[i];
        filename = replace(file, ".czi", "");

        // open(input_path + file);
		// open image using Bio-Formats
		run("Bio-Formats", "open=[" + input_path + "/" + file +"] autoscale");

        selectWindow(file);
        run("Scale Bar...", "width=" + width + " height=" + height + " font=" + font + " color=White background=None location=[Lower Right] bold overlay");

        //saveAs("Tiff", output_path + filename + ".tiff");
        saveAs("PNG", output_path + filename + ".png");

        close();
    }

}

//				input_path, 						output_path, 					width, height, font
addScaleBar('/Users/u0125404/Desktop/P62/', '/Users/u0125404/Desktop/P62/with_scalebar/', 20, 5, 18);

You chose to add the scale bar as an Overlay (as indicated by the keyword overlay in your recorded macro command). Remove this keyword to “burn” the scale bar into the image.

Do you open the *.tif with ImageJ again or do you open the images with another application.
You store the image scalebar as an overlay which cannot be read by other image application.

If you don’t create a scalebar as overlay you will see it in other applications, too (e.g., IrfanView).

Here a macro example with and without an overlay:

run("Blobs (25K)");
run("Scale Bar...", "width=80 height=4 font=14 color=White background=None location=[Lower Right] bold");


run("Blobs (25K)");
run("Scale Bar...", "width=80 height=4 font=14 color=White background=None location=[Lower Right] bold overlay");
1 Like

Thx all, removing the “overlay” indeed worked!