Question

Im making my own mp3 tagger, and everything is fine so far. Although im stuck reading the album art tag.

I would like to know how to display the cover in a C#.NET picture box, but everything iv seen about that particular tag is confusing me.

I know i can get tags from files like this

txtAlbum.Text = currentFile.Tag.Album;

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

Any help would be greatly appreciated, and thank you for your valued time.

Was it helpful?

Solution

Try this

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);
        }

OTHER TIPS

here's my quick and short solution for that problem:

var file = TagLib.File.Create(filename);
var bin = (byte[])(file.Tag.Pictures[0].Data.Data);
imageBox.Image = Image.FromStream(new MemoryStream(bin));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top