C # mp3 ID tags with taglib - album cover

I create my own mp3 tagger and everything is still fine. Although I'm stuck reading the album cover tag.

I would like to know how to display the cover art in a C # .NET image window, but everything that is visible by this particular tag is confusing to me.

I know that I can get tags from such files

txtAlbum.Text = currentFile.Tag.Album; 

but all i need to do is grab the image from the file and hit it in the picture. Then I would like to know how to write a picture (jpg, png) to a file and overwrite the existing one.

Any help would be greatly appreciated and thanks for your valuable time.

+6
source share
2 answers

try it

 TagLib.File tagFile = TagLib.File.Create(path); IPicture newArt = new Picture(tmpImg); tagFile.Tag.Pictures = new IPicture[1] {newArt}; tagFile.Save(); 

EDIT

 var file = TagLib.File.Create(filename); if (file.Tag.Pictures.Length >= 1) { var bin = (byte[])(file.Tag.Pictures[0].Data.Data); PreviewPictureBox.Image = Image.FromStream(new MemoryStream(bin)).GetThumbnailImage(100, 100, null, IntPtr.Zero); } 
+9
source

here is my quick and short solution for this problem:

 var file = TagLib.File.Create(filename); var bin = (byte[])(file.Tag.Pictures[0].Data.Data); imageBox.Image = Image.FromStream(new MemoryStream(bin)); 
+3
source

Source: https://habr.com/ru/post/913730/


All Articles