Extract Job Identifier / TransmissionReference from image in C#

294 views Asked by At

I need to extract some metadata for a system.

I already have the following code, which is working for all others metadata attributes I need to access.

using (Stream stream = new FileStream(imagePhysicalPath, FileMode.Open, FileAccess.Read, FileShare.Read))
{
    var decoder = new JpegBitmapDecoder(stream, BitmapCreateOptions.None, BitmapCacheOption.None);
    var metadata = decoder.Metadata ?? decoder.Frames[0].Metadata as BitmapMetadata;

    if (metadata != null)
    {
        object job_identifier = metadata.GetQuery("/xmp/photoshop:TransmissionReference");
    }
}

However, it does't work for the Job Identifier / Transmission Reference. How can I read this data from an Image?

2

There are 2 answers

0
Justin Lessard On BEST ANSWER

The solution is to use this query instead: /app13/irb/8bimiptc/iptc/{str=Original Transmission Reference}

using (Stream stream = new FileStream(imagePhysicalPath, FileMode.Open, FileAccess.Read, FileShare.Read))
{
    var decoder = new JpegBitmapDecoder(stream, BitmapCreateOptions.None, BitmapCacheOption.None);
    var metadata = decoder.Frames[0].Metadata as BitmapMetadata;

    if (metadata != null)
    {
        object job_identifier = metadata.GetQuery("/app13/irb/8bimiptc/iptc/{str=Original Transmission Reference}");
    }
}
0
Carlos On

I would say the problem is

  1. your variable metadata is holding the value for decode.Metadata because it is not null
  2. metadata for /xmp/photoshop:TransmissionReference is on decoder.Frames[0].Metadata