Login  Register

Re: add/edit a comment and store it with an image?

Posted by Bill Christens-Barry on Feb 15, 2011; 3:06pm
URL: http://imagej.273.s1.nabble.com/add-edit-a-comment-and-store-it-with-an-image-tp3685672p3685673.html

Norbert,

This seems to work here (Mac OS 10.6.5; Java 1.6, ImageJ 1.45b4), :

macro "Create Demo image [F1]"{
        newImage("A", "8-bit Ramp", 280, 250, 1);
        setMetadata("Info", "old text");
}

macro"Show Info [F2]"{
        info = getMetadata("Info");
        title1 = "Description";
        title2 = "["+title1+"]";
        f = title2;
        if (isOpen(title1)){
                selectWindow(title1);
                print(f, "\\Update:"); // clears the window
        }
        else
                run("Text Window...", "name="+title2+" menu");
        print(f, "new text");
}

macro "Store Info[F3]"{
        selectWindow("Description");
        str = getInfo("window.contents");
        selectWindow("A");
        setMetadata("info", str);
}

The window focus of "Store Info" has been explicitly set to "Description". Otherwise, the window.contents of the window "Macro" (which I had created to hold and run your test macros) was itself copied into the metadata.

Bill Christens-Barry