Extracting a jpeg or png from an audio file using TagLib Sharp

Started by kgs1951,

kgs1951

I am trying to extract a picture from an audio file using TagLib sharp.

I have gotten to this point using vb.net and need help with the rest of the code.

Dim file As TagLib.File = TagLib.File.Create(MusicFile) 'MusicFile is my path to the audio file.

If file.Tag.Pictures.Length > 0 Then
    Dim pict As TagLib.IPicture = file.Tag.Pictures(0)


    Dim imgdata As ByteVector
    imgdata = pict.Data.Data


End If

radio42

I am not into VB, but in C# it would be equivalent to this (as you get a byte array out of TagLib):
System.Drawing.ImageConverter imageConverter = new System.Drawing.ImageConverter();

System.Drawing.Bitmap bm =
    (System.Drawing.Bitmap)imageConverter.ConvertFrom(byteArray);