title: Display Metadata-thumbnail of Jpeg in picturebox
body: <p>I need to display a Image's thumbnail, that is saved in its Metadata in a picturebox. I'm using VB.NET</p>
  
  <p><a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ee719904%28v=vs.85%29.aspx#_jpeg_metadata" rel="nofollow">http://msdn.microsoft.com/en-us/library/windows/desktop/ee719904%28v=vs.85%29.aspx#_jpeg_metadata</a></p>
  
  <p>So far i came up with this. Adding a breakpoint displays that GETQUERY returns empty even if i know that the file does indeed have a thumbnail</p>
  
  <pre><code>    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
      Dim imagepath = "C:\xampp\htdocs\Downloads\IMG_1322.JPG" ' path to file
      Dim stream = New FileStream(imagepath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)
      Dim decoder = New JpegBitmapDecoder(stream, BitmapCreateOptions.None, BitmapCacheOption.None)
      Dim metadata = TryCast(decoder.Frames(0).Metadata, BitmapMetadata)
  
      Dim ms As New System.IO.MemoryStream
  
      Dim bm As Bitmap
      Dim arData() As Byte
  
      arData = metadata.GetQuery("/app0/{ushort=6}") '&lt;--- Breakpoint here: Query returns nothing!
  
  
      ms.Write(arData, 78, arData.Length - 78)
  
      bm = New Bitmap(ms)
  
      PictureBox1.Image = bm
      stream.Close()
  
  End Sub
  </code></pre>