Task
In PowerShell, I want to add a picture as ID3V2 tag with the help of taglip-sharp library.
Usually you do it this way:
# Load taglib-sharb library
[Reflection.Assembly]::LoadFrom( (Resolve-Path "..\Common\taglib-sharp.dll"))
# Load MP3 file
$media = [TagLib.File]::Create("C:\MusicFile.mp3")
# Load picture
$pic = [taglib.picture]::createfrompath("C:\MyAlbumArt.jpg")
# Add picture to MP3
$media.Tag.Pictures = $pic
# Save Mp3
$media.Save()
General problem
The above works only if your picture is a file located somewhere locally.
But I have a picture as [System.Drawing.Bitmap]
object which has no filepath to load it with createfrompath
.
Before you say Then just write it to disc: I'd rather avoid saving them since my final script processes many pictures and mp3 files. And I don't want to write and delete hundreds of pictures.
Specific question
I see that taglib also has another method called CreateFromFile(File.IFileAbstraction )
to load a picture. But how do I convert a [System.Drawing.Bitmap]
into a IFileAbstraction
?
The closest help I found on the net was here and here. But it's for .NET 4.5 and I am by no means able to convert this into PowerShell syntax
Here is the documentation of taglib-sharp's picture object if it helps.