public override void Completed(IndexedReader reader, int tiffHeaderOffset)
 {
     if (_storeThumbnailBytes)
     {
         // after the extraction process, if we have the correct tags, we may be able to store thumbnail information
         var thumbnailDirectory = Directories.OfType<ExifThumbnailDirectory>().FirstOrDefault();
         if (thumbnailDirectory != null && thumbnailDirectory.ContainsTag(ExifDirectoryBase.TagCompression))
         {
             int offset;
             int length;
             if (thumbnailDirectory.TryGetInt32(ExifThumbnailDirectory.TagThumbnailOffset, out offset) &&
                 thumbnailDirectory.TryGetInt32(ExifThumbnailDirectory.TagThumbnailLength, out length))
             {
                 try
                 {
                     var thumbnailData = reader.GetBytes(tiffHeaderOffset + offset, length);
                     thumbnailDirectory.ThumbnailData = thumbnailData;
                 }
                 catch (IOException ex)
                 {
                     thumbnailDirectory.AddError("Invalid thumbnail data specification: " + ex.Message);
                 }
             }
         }
     }
 }
        /// <summary>Reads JFXX values and returns them in an <see cref="JfxxDirectory"/>.</summary>
        public JfxxDirectory Extract(IndexedReader reader)
        {
            var directory = new JfxxDirectory();

            try
            {
                // For JFIF the tag number is the value's byte offset
                directory.Set(JfxxDirectory.TagExtensionCode, reader.GetByte(JfxxDirectory.TagExtensionCode));
            }
            catch (IOException e)
            {
                directory.AddError(e.Message);
            }

            return directory;
        }
        /// <summary>Reads JFIF values and returns them in an <see cref="JfifDirectory"/>.</summary>
        public JfifDirectory Extract(IndexedReader reader)
        {
            var directory = new JfifDirectory();

            try
            {
                // For JFIF the tag number is the value's byte offset
                directory.Set(JfifDirectory.TagVersion,     reader.GetUInt16(JfifDirectory.TagVersion));
                directory.Set(JfifDirectory.TagUnits,       reader.GetByte(JfifDirectory.TagUnits));
                directory.Set(JfifDirectory.TagResX,        reader.GetUInt16(JfifDirectory.TagResX));
                directory.Set(JfifDirectory.TagResY,        reader.GetUInt16(JfifDirectory.TagResY));
                directory.Set(JfifDirectory.TagThumbWidth,  reader.GetByte(JfifDirectory.TagThumbWidth));
                directory.Set(JfifDirectory.TagThumbHeight, reader.GetByte(JfifDirectory.TagThumbHeight));
            }
            catch (IOException e)
            {
                directory.AddError(e.Message);
            }

            return directory;
        }
            Extract(IndexedReader reader, int readerOffset = 0)
        {
            var directories = new List<Directory>();

            try
            {
                // Read the TIFF-formatted Exif data
                TiffReader.ProcessTiff(reader, new ExifTiffHandler(directories, StoreThumbnailBytes), readerOffset);
            }
            catch (TiffProcessingException e)
            {
                // TODO what do to with this error state?
                Console.Error.WriteLine(e);
            }
            catch (IOException e)
            {
                // TODO what do to with this error state?
                Console.Error.WriteLine(e);
            }

            return directories;
        }
 /// <exception cref="System.IO.IOException"/>
 public override bool CustomProcessTag(int tagOffset, ICollection<int> processedIfdOffsets, int tiffHeaderOffset, IndexedReader reader, int tagId, int byteCount)
 {
     // Custom processing for the Makernote tag
     if (tagId == ExifDirectoryBase.TagMakernote && CurrentDirectory is ExifSubIfdDirectory)
     {
         return ProcessMakernote(tagOffset, processedIfdOffsets, tiffHeaderOffset, reader);
     }
     // Custom processing for embedded IPTC data
     if (tagId == ExifDirectoryBase.TagIptcNaa && CurrentDirectory is ExifIfd0Directory)
     {
         // NOTE Adobe sets type 4 for IPTC instead of 7
         if (reader.GetSByte(tagOffset) == 0x1c)
         {
             var iptcBytes = reader.GetBytes(tagOffset, byteCount);
             Directories.Add(new IptcReader().Extract(new SequentialByteArrayReader(iptcBytes), iptcBytes.Length));
             return true;
         }
         return false;
     }
     return false;
 }
 public abstract bool CustomProcessTag(int tagOffset, ICollection<int> processedIfdOffsets, int tiffHeaderOffset, IndexedReader reader, int tagId, int byteCount);
 public abstract void Completed(IndexedReader reader, int tiffHeaderOffset);