title: Read EXIF-Thumbnail from JPEG
body: <p>I need a performant way to extract a thumbnail from a jpg-file without reading the whole file. </p>
  
  <p>I wrote this method, which should work well - but it doesn't. The new file can not be read. Where is my mistake?</p>
  
  <pre><code>public static System.Drawing.Image GetThumbnail(string Image)
  {
      try
      {
          List&lt;byte&gt; image = new List&lt;byte&gt;();
          byte[] _startToken = new byte[2] { 0xFF, 0xD8 }; //JPEG Start
          byte[] _endToken = new byte[2] { 0xFF, 0xD9 }; //JPEG End
          byte[] buff = new byte[2];
          FileStream fs = new FileStream(Image, FileMode.Open, FileAccess.Read);
          BinaryReader br = new BinaryReader(fs);
          while (br.BaseStream.Position &lt; br.BaseStream.Length)
          {
              byte bCurrent = br.ReadByte();
              buff[0] = buff[1];
              buff[1] = bCurrent;
              if (Enumerable.SequenceEqual(buff, _startToken))
              {
                  image.Clear();
                  image.AddRange(buff);
              };
              if (Enumerable.SequenceEqual(buff, _endToken))
              {
                  break;
              };
              image.Add(bCurrent);
          }
          return (Bitmap)((new ImageConverter()).ConvertFrom(image.ToArray()));
      }
      catch
      {
          return null;
      }
  }
  </code></pre>