[ImageJ-devel] Accessing metadata from C

Luc Deschenaux luc at miprosoft.com
Fri Oct 25 10:46:18 CDT 2013


Thanks Curtis,

for now i'll just use tiffinfo to extract the XML i need..

#!/bin/sh
INFO=$(tiffinfo "$1" 2>&1 | sed -r -n -e '/Warning/b' -e 's/.*Tag 50839: 
*//p')

doit() {
   node | xmlstarlet fo
}

doit << EOF
   console.log(
     new Buffer([$INFO])
     .toString('utf8')
     .replace(/\0|\n/g,'')
     .replace(/^[^<]+<\?xml/,'<?xml')
     .replace(/\/properties>.*/,'/properties>')
   );
EOF

On 22/10/13 18:10, Curtis Rueden wrote:
> Hi Luc,
>
> > I cannot figure out how to access metadata('Info') in a TIFF file,
> > without launching ImageJ in batch mode to call getMetadata('Info')
> > ...
> >
> > Is it possible with FreeImage or any other C library ?..
>
> The metadata text is written out to the TIFF using custom tags 50838 
> and 50839.
>
> Using libtiff's tiffinfo command line tool, you'll see something like:
>
>   Tag 50839: 
> 73,74,73,74,105,110,102,111,0,0,0,1,0,72,0,101,0,108,0,108,0,111,0,32,0,119,0,111,0,114,0,108,0,100,0,46,0,46,0,46,0,10,0,71,0,114,0,101,0,97,0,116,0,46
>
> Which must then be decoded to a string.
>
> Source code at:
> https://github.com/fiji/ImageJA/blob/v1.48e/src/main/java/ij/io/TiffEncoder.java#L355
> https://github.com/fiji/ImageJA/blob/v1.48e/src/main/java/ij/io/TiffDecoder.java#L43
>
> Regards,
> Curtis
>
> P.S. Looks like someone submitted a patch to support this in Pillow, 
> but it is not yet merged:
> https://github.com/python-imaging/Pillow/issues/291. Who knows what 
> other software already supports it.
>
>
> On Tue, Oct 22, 2013 at 10:30 AM, Luc Deschenaux <luc at miprosoft.com 
> <mailto:luc at miprosoft.com>> wrote:
>
>     Hi,
>
>     I cannot figure out how to access metadata('Info') in a TIFF file,
>     without launching ImageJ in batch mode to call getMetadata('Info') ...
>
>     Is it possible with FreeImage or any other C library ?..
>
>     Regards,
>
>     Luc
>
>     _______________________________________________
>     ImageJ-devel mailing list
>     ImageJ-devel at imagej.net <mailto:ImageJ-devel at imagej.net>
>     http://imagej.net/mailman/listinfo/imagej-devel
>
>


-- 
Luc Deschenaux

t: +41 788 266 366
v: +41 225 085 085 @ netvoip.ch

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://imagej.net/pipermail/imagej-devel/attachments/20131025/811c95c9/attachment.html>


More information about the ImageJ-devel mailing list