What is the best way to read an IPTC header from an image? W#

2

What is the best way to read the IPTC header of an image? I have the following image and I had to read the description of it (for a bank of images), but I already researched many forms that were confusing for me. Has anyone done this and can you tell me the best way? I am using C # technology. Here's what I want to read in the picture:

    
asked by anonymous 25.05.2017 / 17:30

1 answer

2

As I see it, System.Windows.Media.Imaging :

var stream = new FileStream("arquivo.jpg", FileMode.Open, FileAccess.Read);
var decoder = new JpegBitmapDecoder(stream, BitmapCreateOptions.None, BitmapCacheOption.None);
var metadata = decoder.Frames[0].Metadata as BitmapMetadata;
if(metadata != null)
    var dados = metadata.Keywords;

A more recent approach uses ExifLib , obtaining the EXIF data, which implements the IPTC:

using (ExifReader reader = new ExifReader(@"arquivo.jpg"))
{
    // Os dados estão em 'reader'.
}

See more here .

    
25.05.2017 / 17:33