Re: Extensible Persistent Properties for ImageJ Images

Posted by Michael P Ellis on
URL: http://imagej.273.s1.nabble.com/Extensible-Persistent-Properties-for-ImageJ-Images-tp5023228p5023263.html

Wayne,

Many thanks for the new setProp()/getProp() functionality. I have however found it does not seem to work when I create my
image with IJ.createHyperStack() or when I create a CompositImage from a Hyperstack

        // Does work
        //img = IJ.createImage("Untitled", "8-bit black", 500, 500, 3);

        // Does not work
        // img = new CompositeImage(IJ.createImage("Untitled", "8-bit black", 500, 500, 3));

        // Does not work
        img = IJ.createHyperStack(“Untitled", 500, 500, 3, 1, 1, 16);

        img.setProp("Banana", "Yellow");
        IJ.showMessage("Bananas are " + img.getProp("Banana") );

        path = IJ.getDir("home")+"Downloads/Untitled.tif";
        IJ.saveAs(img, "Tiff", path);
        img2 = IJ.openImage(path);

        IJ.showMessage("Bananas are " + img2.getProp("Banana") );


The the properties seem to be assignable to the hyperstack but are lost on save or restore.


— Michael Ellis


> On 17 Apr 2020, at 19:16, Michael Ellis <[hidden email]> wrote:
>
>> img = IJ.createImage("Untitled", "8-bit black", 500, 500, 3);
>> clown = IJ.openImage("http://wsr.imagej.net/images/clown.jpg");
>> bytes = new FileSaver(clown).serialize();
>> string = Base64.getEncoder().encodeToString(bytes);
>> img.setProp("clown", string);
>> text = "Clown.jpg was serialized, set as an image\n"
>>    + "property, the image was saved, re-opened,\n"
>>    + "and clown.jpg was deserialized and displayed.";
>> img.setProp("text", text);
>> path = IJ.getDir("home")+"Downloads/Untitled.tif";
>> IJ.saveAs(img, "Tiff", path);
>> img2 = IJ.openImage(path);
>> string2 = img2.getProp("clown");
>> bytes2 = Base64.getDecoder().decode(string2);
>> clown2 = new Opener().deserialize(bytes2);
>> clown2.show();
>> IJ.showMessage(img2.getProp("text"));

Michael Ellis (Managing Director)
Digital Scientific UK Ltd.
http://www.dsuk.biz
[hidden email]
tel: +44(0)1223 911215

The Commercial Centre
6 Green End
Cambridge
CB23 7DY

=== END OF EMAIL ===

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html