#pragma warning restore IDE0032 // Use auto property public ParserIFDEntry(EndianBinaryReader reader, ExifSection section) { entry = new IFDEntry(reader); offsetIsBigEndian = reader.Endianess == Endianess.Big; Section = section; }
public MetadataOffset(ExifSection section, uint offset) { Section = section; Offset = offset; }
private static List <ParserIFDEntry> ParseDirectories(EndianBinaryReader reader, uint firstIFDOffset) { List <ParserIFDEntry> items = new(); bool foundExif = false; bool foundGps = false; bool foundInterop = false; Queue <MetadataOffset> ifdOffsets = new(); ifdOffsets.Enqueue(new MetadataOffset(ExifSection.Image, firstIFDOffset)); while (ifdOffsets.Count > 0) { MetadataOffset metadataOffset = ifdOffsets.Dequeue(); ExifSection section = metadataOffset.Section; uint offset = metadataOffset.Offset; if (offset >= reader.Length) { continue; } reader.Position = offset; ushort count = reader.ReadUInt16(); if (count == 0) { continue; } items.Capacity += count; for (int i = 0; i < count; i++) { ParserIFDEntry entry = new(reader, section); switch (entry.Tag) { case TiffConstants.Tags.ExifIFD: if (!foundExif) { foundExif = true; ifdOffsets.Enqueue(new MetadataOffset(ExifSection.Photo, entry.Offset)); } break; case TiffConstants.Tags.GpsIFD: if (!foundGps) { foundGps = true; ifdOffsets.Enqueue(new MetadataOffset(ExifSection.GpsInfo, entry.Offset)); } break; case TiffConstants.Tags.InteropIFD: if (!foundInterop) { foundInterop = true; ifdOffsets.Enqueue(new MetadataOffset(ExifSection.Interop, entry.Offset)); } break; case TiffConstants.Tags.StripOffsets: case TiffConstants.Tags.RowsPerStrip: case TiffConstants.Tags.StripByteCounts: case TiffConstants.Tags.SubIFDs: case TiffConstants.Tags.ThumbnailOffset: case TiffConstants.Tags.ThumbnailLength: // Skip the thumbnail and/or preview images. // The StripOffsets and StripByteCounts tags are used to store a preview image in some formats. // The SubIFDs tag is used to store thumbnails in TIFF and for storing other data in some camera formats. // // Note that some cameras will also store a thumbnail as part of their private data in the EXIF MakerNote tag. // The EXIF MakerNote tag is treated as an opaque blob, so those thumbnails will be preserved. break; default: items.Add(entry); break; } System.Diagnostics.Debug.WriteLine(entry.ToString()); } } return(items); }