Re: Extensible Persistent Properties for ImageJ Images

Posted by Wayne Rasband-2 on
URL: http://imagej.273.s1.nabble.com/Extensible-Persistent-Properties-for-ImageJ-Images-tp5023228p5023264.html

> On Apr 25, 2020, at 8:30 AM, Michael Ellis <[hidden email]> wrote:
>
> 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

These bugs are fixed in the 1.53a16 daily build. Source code changes are on the Git repository at
   https://github.com/imagej/imagej1/commit/7ef1684430547d84dcb508579e52a49ec1a7c568

-wayne


> // 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"));

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