Giter Club home page Giter Club logo

xmp-core-dotnet's Introduction

Build status XmpCore NuGet version XmpCore NuGet download count

This library is a port of Adobe's XMP SDK to .NET.

The API should be familiar to users of Adobe's XMPCore 6.1.10, though it has been modified in places to better suit .NET development.

Sample Usage

IXmpMeta xmp;
using (var stream = File.OpenRead("some-file.xmp"))
    xmp = XmpMetaFactory.Parse(stream);

foreach (var property in xmp.Properties)
    Console.WriteLine($"Path={property.Path} Namespace={property.Namespace} Value={property.Value}");

XmpMetaFactory has other methods for reading from string and byte[], as well as support for parsing options. Returned properties provide additional information, but the above example should be enough to get you started.

Installation

The easiest way to reference this project is to install the XmpCore package:

PM> Install-Package XmpCore

The NuGet package has no other dependencies.

As of version 6.1.10.1 the package is now strong named. Before then, a separate XmpCore.StrongName package exists.

Framework support

The project targets net35 and netstandard1.0, meaning you can use it pretty much anywhere these days.

History

Initially ported by Yakov Danila and Nathanael Jones, the project is now maintained by Drew Noakes and contributors on GitHub.

License

The same BSD license applies to this project as to Adobe's open source XMP SDK, from which it is derived.

xmp-core-dotnet's People

Contributors

drewnoakes avatar iamcarbon avatar kwhopper avatar lilith avatar michaelosthege avatar numpsy avatar pietervp avatar tasteful avatar tehkyle avatar trylock avatar ydanila avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xmp-core-dotnet's Issues

Support for UTF-16 and UTF-32?

Is there any plans to support UTF-16 and UTF-32 encoded XMP metadata?

This library is perfect for my use except for the support of these encodings.

Implement Language property for XmpProperty682

XmpProperty682 currently always returns null for the Language property even when an xml:lang qualifier is present and the Options flag HasLanguage is true. I ran into this trying to enumerate the localization languages available for descriptions, copyrights, etc. Using XmpMeta.GetArrayItem to enumerate the localized text entries returns XmpProperty682 properties. XmpMeta.GetLocalizedText is the only way to get an XmpProperty407 property, which requires knowing what the Language will be.

It would seem all XmpProperty682.Language would have to do is test the Options.HasLanguage flag to either return the same value as XmpProperty407 or null as it does now.

...Jim Hansen

UTF-16 is not supported

Thanks for the Sample usage example. I have tried this on some files with XMP tags (generated by Picasa), and I get the following exception : "UTF-16 is not a supported encoding.". Do you have any advice on how to overcome this please? (the tags show up ok when checked at: http://exif.regex.info/exif.cgi )

XmpMetaFactory.ParseFromBuffer fails when there is an XML-comment in the input XML buffer

I think the title explains it quite good. I get an exception:

  HResult=0x80004002
  Message=Unable to cast object of type 'System.Xml.Linq.XComment' to type 'System.Xml.Linq.XElement'.
  Source=XmpCore.StrongName
  StackTrace:
   at XmpCore.Impl.ParseRdf.Rdf_NodeElementList(XmpMeta xmp, XmpNode xmpParent, XElement rdfRdfNode, ParseOptions options)
   at XmpCore.Impl.XmpMetaParser.ParseXmlDoc(XDocument document, ParseOptions options)
   at XXX.cs:line 44
   at XXX.Test.cs:line 116

This will probably also be true for other similar XNodes (processing instruction, ...?)

XmpMetaFactory.SerializeToString returning a string with a BOM at the start?

Hi,
I've been doing some testing with reading and modifying some existing XMP, and then converting back to a string with XmpMetaFactory.SerializeToString and it appears to me as though the the returned string has a BOM at the start?

I noticed because If I try to convert the XMP to a string and then parse that straight back with XmpMetaFactory.ParseFromString then this happens:

image

And then the first character is this:

image

and if I trim out the first character then the parse works.

Is this correct?

Thanks.

System.Xml.XmlException: The ':' character, hexadecimal value 0x3A, cannot be included in a name.

Hi there,

System.Xml.XmlException: The ':' character, hexadecimal value 0x3A, cannot be included in a name.

I'm trying to use XMPCore.net inside a PCL, and get the above error when using XmpCore.Portable.

I've successfully integrated it into a normal C# library and have several unit tests with accompanying test documents containing XMP. They work just fine with the 'regular' XmpCore.

However when reusing the same code, unit tests and sample documents I get an XML Error with the Portable XMPCore when trying to parse the XMP (from string or buffer). The XMP verifies just fine on w3c and indeed is successfully parsed using non portable XMPCore.

I've tried registering the namespace before parsing with no luck, any ideas?

Thanks for any help,
Chris

xmp-core-dotnet bug from java port

As described in detail here: drewnoakes/metadata-extractor-dotnet#418 by @Numpsy and confirmed by @kwhopper, it seems like there's a bug from the java import of xmp-core-dotnet, where, if rdf namespace definition is attached to the <x:xmpmeta node (correct behaviour as per C++ version of XMP-toolkit-sdk) rather than the rdf:RDF node (the way xmp-core-dotnet expects it but is incorrect behaviour), xmp-core-dotnet throws an error

I have a MissingMethodException: Method not found: 'System.Xml.XmlReaderSettings.set_MaxCharactersFromEntities' issue

MissingMethodException: Method not found: 'System.Xml.XmlReaderSettings.set_MaxCharactersFromEntities'.
XmpCore.Impl.XmpMetaParser.ParseXmlFromByteBuffer (XmpCore.Impl.ByteBuffer buffer, XmpCore.Options.ParseOptions options)
XmpCore.Impl.XmpMetaParser.Extract (System.Byte[] bytes, XmpCore.Options.ParseOptions options)
XmpCore.XmpMetaFactory.ExtractXDocumentFromBuffer (System.Byte[] buffer, XmpCore.Options.ParseOptions options)

I have a xmlReader.Settings.MaxCharactersFromEntities under Unity3d.
but no System.Xml.XmlReaderSettings.set_MaxCharactersFromEntities AFAIK?

Any clues?

I do a byte[] imageArray = System.IO.File.ReadAllBytes(fullpath);
then simply

        xmp = (IXmpMeta)XmpMetaFactory.ExtractXDocumentFromBuffer(imageArray);

        foreach (var property in xmp.Properties)
            Debug.Log(string.Format("Path={0} Namespace={1} Value={2}", 
        property.Path, property.Namespace, property.Value));

Is that wrong?

.net 3.5

I also tried just brute forcing the string in like

       byte[] imageArray = System.IO.File.ReadAllBytes(fullpath);

        XmlDocument docx = Twobob.BrutalXMP.ExtractXmpBytes(imageArray);

        xmp = XmpMetaFactory.ParseFromString(docx.OuterXml);

'Where the ExtractXmpBytes is tested as working okay, But I got the same error so... confuzzled

and also xmp = XmpMetaFactory.ParseFromBuffer(imageArray); fails similarly so I am guessing this is to do with the calls the XmpMetaFactory class is placing internally.

FWIW: xmp = XmpMetaFactory.Create(); does not fail

License is not available

Hello @drewnoakes,

The license is not available and the link available in the README.md file is broken. I guess the license should be:
https://web.archive.org/web/20120911161309/http://www.adobe.com/devnet/xmp/library/eula-xmp-library-java.html
but I am not sure. Please let me know if the below BSD license version is correct and add a correct one if possible.

The BSD License
Copyright (c) 2009, Adobe Systems Incorporated All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

  • Neither the name of Adobe Systems Incorporated, nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANT ABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Create Array of Structs

I can't find anything online on how to create an array of structs.

There is AppendArrayItem, but it takes a string as it's value, but I need it to be the actual struct. How do you make that work?

Thanks!

Add UTF-32 support (or improve error messaging?)

Hello,

I'm trying to use the library to extract metadata from an mp4 file taken with an Android phone. I'm running:

using var stream = File.OpenRead("C:\...\movie.mp4");
var xmp = XmpMetaFactory.Parse(stream);

This fails with:

System.NotSupportedException: UTF-32 is not a supported encoding.
   at XmpCore.Impl.ByteBuffer.GetEncoding()
   at XmpCore.Impl.Latin1Converter.Convert(ByteBuffer buffer)
   at XmpCore.Impl.XmpMetaParser.ParseXmlFromByteBuffer(ByteBuffer buffer, ParseOptions options)
   at XmpCore.Impl.XmpMetaParser.ParseXmlFromInputStream(Stream stream, ParseOptions options)
   at XmpCore.Impl.XmpMetaParser.Parse(Stream stream, ParseOptions options)
   at XmpCore.XmpMetaFactory.Parse(Stream stream, ParseOptions options)

Looking at the code, I saw that this was following the AcceptLatin1 path so I also tried:

var xmp = XmpMetaFactory.Parse(stream, new() { AcceptLatin1 = false });

This fails with:

XmpCore.XmpException: Unsupported Encoding
 ---> XmpCore.XmpException: XML parsing failure
 ---> System.Xml.XmlException: '.', hexadecimal value 0x00, is an invalid character. Line 1, position 1.
   at System.Xml.XmlTextReaderImpl.Throw(Exception e)
   at System.Xml.XmlTextReaderImpl.Throw(String res, String[] args)
   at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace()
   at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
   at System.Xml.XmlTextReaderImpl.Read()
   at System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options)
   at System.Xml.Linq.XDocument.Load(XmlReader reader)
   at XmpCore.Impl.XmpMetaParser.ParseStream(Stream stream, ParseOptions options)
   --- End of inner exception stack trace ---
   at XmpCore.Impl.XmpMetaParser.ParseStream(Stream stream, ParseOptions options)
   at XmpCore.Impl.XmpMetaParser.ParseXmlFromByteBuffer(ByteBuffer buffer, ParseOptions options)
   --- End of inner exception stack trace ---
   at XmpCore.Impl.XmpMetaParser.ParseXmlFromByteBuffer(ByteBuffer buffer, ParseOptions options)
   at XmpCore.Impl.XmpMetaParser.ParseXmlFromInputStream(Stream stream, ParseOptions options)
   at XmpCore.Impl.XmpMetaParser.Parse(Stream stream, ParseOptions options)
   at XmpCore.XmpMetaFactory.Parse(Stream stream, ParseOptions options)

Is there a reason why UTF-32 is not supported? Or is the real issue that the file lacks XMP metadata and this is just a misleading error message?

VS2017 / C# 7 support

Last week VS2017 was released along with C# 7.

Does anyone have any reservations about the project upgrading? This would cause the solution to not build under VS2015, however you could still use the NuGet package in earlier version(s) of Visual Studio just fine.

XMP Toolkit SDK - 2016.07 support?

Adobe has released a new XMP Toolkit:

http://www.adobe.com/devnet/xmp.html

Do you want to support the latest? Would it replace the current 'master' codebase, or should it live as another permanent branch so the current remains available?

I'm happy to try and start support, although there's no way of knowing how long it might take. Thanks

Support for PCL

Any thoughts on converting this to be usable in a PCL library?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.