Powershell - Set 'title' in photo file using Taglib-sharp not working

不打扰是莪最后的温柔 提交于 2019-12-24 11:57:58

问题


I'm trying to change the 'title' (extended file attribute) in multiple photos using Taglib-Sharp in Powershell. While it works fine for most, it doesn't for certain photos. So far from my initial testing it appears to not work with Olympus produced JPEG's or JPEG's without any EXIF info in them at all.

I'm using TagLib-Sharp 2.1.0.0, I've tried older version's too.

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

The photos all appear fine and I can manually set the TITLE without issue in Windows Explorer.

I've no prior experience in this area and am new to Powershell - can anyone help?

来源:https://stackoverflow.com/questions/16654469/powershell-set-title-in-photo-file-using-taglib-sharp-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!