Powershell - set the "name" in the photo file using Taglib-sharp, does not work

I am trying to change the "title" (extended file attribute) in several photos using Taglib-Sharp in Powershell. Although it works great for most, it is not suitable for certain photos. So far, starting with my initial testing, it seems like it does not work with Olympus created by JPEG or JPEG, without any EXIF ​​data in them at all.

I am using TagLib-Sharp 2.1.0.0, I also tried the old version.

This is my code:

[Reflection.Assembly]::LoadFrom( ("c:\taglib-sharp.dll") ) $media = [TagLib.File]::Create("C:\temp\photo.jpg") $media.ImageTag.Title = "Test Title" $media.save() 

This is the error I get:

 PS C:\Users\tris> C:\Write_tag_taglib-sharp.ps1 GAC Version Location --- ------- -------- False v2.0.50727 c:\taglib-sharp.dll Exception calling "Save" with "0" argument(s): "File not writeable. Corrupt metadata?" At C:\Write_tag_taglib-sharp.ps1:4 char:1 + $media.save() + ~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : InvalidOperationException 

All the photos look great, and I can manually install TITLE without problems in Windows Explorer.

I have no previous experience in this area and am new to Powershell - can anyone help?

+1
source share

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


All Articles