metadata-extractor-dotnet icon indicating copy to clipboard operation
metadata-extractor-dotnet copied to clipboard

Support editing metadata

Open urza opened this issue 9 years ago • 12 comments

Hi, this looks fantastic. Can it also edit and save metadata to files? Or just read? If not, can you recommend any c# library for writing metadata? (description, comments, tags) Thnaks

urza avatar Sep 06 '15 17:09 urza

No support for writing metadata at this stage. Hopefully one day, but there is no ETA for this.

As for other options I can not make any recommendations. If you find anything, please do report back on this issue. Thanks!

drewnoakes avatar Sep 06 '15 22:09 drewnoakes

One option could be to write back to an XMP file, and perhaps add support to read from the XMP semi-automatically (i.e. where platforms support interrogating the file system, and the method overload allows)?

RowlandShaw avatar Oct 04 '16 08:10 RowlandShaw

Hi folks, I have a working implementation for writing XMP metadata. There are a few things required in XmpCore too, so I am creating several pull requests...

  1. PR15 on XmpCore > addition of two methods to XmpCore.XMPMetaFactory and XmpCore.Impl.XmpMetaParser
  2. PR #65 > addition of XDocument Root property to MetadataExtractor.Formats.Xmp.XmpDirectory and two lines in MetadataExtractor.Formats.Xmp.XmpReader.Extract, addition of MetadataExtractor.ImageMetadataWriter and MetadataExtractor.Formats.Jpeg.JpegMetadataSubstitutor for substituting XMP in existing Jpeg files

Please note that my implementation works at the level of the XDocument.

I'm looking forward to depend my project on the NuGet packages again when all of this is merged...

cheers, Michael

michaelosthege avatar Oct 23 '16 13:10 michaelosthege

Is there any updates on PR #65 ? I also need to write (or rather delete) some XMP metadata, and I have not been able to achieve this. In Python with libxmp, I can do this:

if xmp.does_property_exist(ns, u'property'):
xmp.delete_property(ns, u'property')

# save stripped XMP header to original image
if xmpfile.can_put_xmp(xmp):
xmpfile.put_xmp(xmp)
xmpfile.close_file()

Is this possible with XMPCore? How do you access the metadata as a xdoc? I've tried this but is failing:

XDocument file = XDocument.Load(filename);
var xmpMeta = XmpMetaFactory.ParseFromXDocument(file);

Selzier avatar Nov 05 '16 17:11 Selzier

PR #65 is waiting for @drewnoakes to be merged (and the NuGet package updated). Then you will be able to substitute the original XMP metadata with modified (or in your case empty) XDocuments.

michaelosthege avatar Nov 05 '16 19:11 michaelosthege

It's been three years, any news on that?

Atulin avatar Jul 14 '19 16:07 Atulin

Checking once again, any news?

cguedel avatar Feb 27 '20 13:02 cguedel

This is a huge feature. I will spare you all the suspense, it's not coming soon and if/when it does come, it'll be broadly announced. There are other tasks we need to complete before we can consider supporting editing metadata.

drewnoakes avatar Feb 27 '20 22:02 drewnoakes

For those wondering, TagLib# supports writing tags, but it's not regularly maintained and seems a bit finicky

whoiskevinrich avatar Apr 09 '21 01:04 whoiskevinrich

If somebody wants to pick up #65 - I've been using this branch without any problems or broken files for years. When somebody picks it up let me know and I will double check that it's fully up to date and so on.

michaelosthege avatar Apr 10 '21 13:04 michaelosthege

@michaelosthege I have been looking at testing your PR (#65) against a use case I have for writing xmp to jpeg. The changes for MDE 2.9.0-rc1 will require refreshing the code to address the change to XmpReader.JpegSegmentPreamble (as per #376 ).

Idea/Suggestion/A shot in the dark:

I complied your PR to a standalone library and tested with some test cases that you had added. The only real change, to do so, was changing JpegSegment class to JpegSegmentPlugin (since it had conflicts with the MDE main branch). Have you considered releasing this as a plugin to the MDE? The idea being, if it is a plugin, it could be tested by folks that are interested in writing capability without any impact on MDE? Perhaps at some point down the line, it could be merged into MDE?

ahsanaman92 avatar Feb 23 '24 19:02 ahsanaman92

@ahsanaman92 it's been ages since I touched that code. The idea with a plugin sounds great, and since you seem to know more much about MDE (and my changes) please feel free to push forward!

michaelosthege avatar Feb 23 '24 20:02 michaelosthege