setProperty

51 views
Skip to first unread message

Nuno Dias

unread,
May 17, 2013, 9:11:14 AM5/17/13
to fiji-...@googlegroups.com
Hello,

Within a script, what would be the correct method for adding metadata to an image being created?
There is the method setProperty under Class ImagePlus, is this the one?
http://rsb.info.nih.gov/ij/developer/api/ij/ImagePlus.html#setProperty(java.lang.String,%20java.lang.Object)

Are there any methods for creating metadata standards (IPTC-IIM, IPTC Core, IPTC Extension, PLUS, Exif or Dublin Core)?

An image made visible using img.show() would keep this added metadata when saved manually by the user or when saved as a .tif by the script iself?

Could I see a little example of how to code for this in Python?

Thanks,
Nuno.
Message has been deleted

Curtis Rueden

unread,
May 31, 2013, 12:49:35 PM5/31/13
to Nuno Dias, Fiji Developers
Hi Nuno,

> I managed to add information to a newly created image

Cool.

As for your other question:
> Are there any methods for creating metadata standards (IPTC-IIM, IPTC
> Core, IPTC Extension, PLUS, Exif or Dublin Core)?

You could of course embed XML containing one of those metadata standards into your ImagePlus, which ImageJ will save to the TIFF comment. But of course ImageJ itself will know nothing about the structure or purpose of that metadata. You'd need custom plugins for that.

Regards,
Curtis


On Fri, May 31, 2013 at 11:46 AM, Nuno Dias <ngd...@gmail.com> wrote:
I managed to add information to a newly created image with:

img = ImagePlus("subimage", cp)

    fi = img.getFileInfo()
    fi.url = 'http://www.flickr.com/'
    img.setFileInfo(fi)
    img.show()
--
--
Please avoid top-posting, and please make sure to reply-to-all!
 
Mailing list web interface: http://groups.google.com/group/fiji-devel
 
---
You received this message because you are subscribed to the Google Groups "Fiji-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fiji-devel+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Nuno Dias

unread,
May 31, 2013, 12:56:19 PM5/31/13
to fiji-...@googlegroups.com
I managed to add text to an image using something like:

img = ImagePlus("subimage", cp)
[create the image]
    fi = img.getFileInfo()
    fi.url = 'http://www.ibmc.up.pt/'
    img.setFileInfo(fi)
    img.show()

and when I go to the menu Image>Show info... I see this added information. But when I save this image as a .tif or .jpg the information is not preserved. Duplicating the image also makes the information disapear.

How can I add metadata info in such a way that it's preserved?
Thanks,
Nuno.

Curtis Rueden

unread,
May 31, 2013, 1:04:33 PM5/31/13
to Nuno Dias, Fiji Developers
Hi Nuno,

How can I add metadata info in such a way that it's preserved?


Thanks,
Nuno.

Nuno Dias

unread,
May 31, 2013, 2:19:14 PM5/31/13
to fiji-...@googlegroups.com, Nuno Dias, ctru...@wisc.edu
Thank you, Curtis. It's really nice you're able to take some time to reply to these small coding problems :)

I can't see any information using the 'description' field as you suggested. Not on FIJI or Adobe Bridge, for example. I do see this tag in Bridge, under description: 'ImageJ=1.47q'. It's there for all images saved from FIJI.
I can still see the unpreserved information from url, like before. This is what I'm using for testing:

from java.util import Random

imp = IJ.createImage("A Random Image", "8-bit", 512, 512, 1)
Random().nextBytes(imp.getProcessor().getPixels())

fi = imp.getFileInfo()
fi.description = 'my_metadata'
fi.url = 'test'
imp.setFileInfo(fi)
imp.show()


Thanks,
Nuno.

Curtis Rueden

unread,
May 31, 2013, 3:10:28 PM5/31/13
to Nuno Dias, Fiji Developers
Hi Nuno,

I can't see any information using the 'description' field as you suggested.

You're right. First of all, it seems to be overwritten, despite what I pointed out in the source code. Secondly, the description is not included in the UI metadata browser.

Sorry,
Curtis




Thanks,
Nuno.

--

Nuno Dias

unread,
Apr 4, 2014, 6:55:47 AM4/4/14
to fiji-...@googlegroups.com, Nuno Dias, ctru...@wisc.edu
Hi Curtis,

I'm digging up this old thread because I ran into another situation where it would be extremely useful to add metadata to newly created file or even to modify a metadata entry in an existing file.
I recently noticed when converting for example .dm3 files to .tiff the metadata is preserved. I had a mental note this was not happening before.

Was there an update to FIJI/ImageJ that introduced an improvement to metadata handling since your last reply? If yes, can I see an example?

Thanks,
Nuno.

Curtis Rueden

unread,
Apr 7, 2014, 4:46:07 PM4/7/14
to Nuno Dias, Fiji Developers
Hi Nuno,

> Was there an update to FIJI/ImageJ that introduced an improvement to
> metadata handling since your last reply? 

Sorry, I don't know.

-Curtis


--
--
Please avoid top-posting, and please make sure to reply-to-all!
 
Mailing list web interface: http://groups.google.com/group/fiji-devel

---
You received this message because you are subscribed to the Google Groups "Fiji-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fiji-devel+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages