Missing namespace when xmp is updated

Dear Aspose Support,

Our client encountered an issue where, after performing an XMP update, certain color profile namespaces are missing from the updated file’s XMP data. These missing namespaces are proprietary and do not belong to our client’s own XMP schema.

For your reference, I’ve attached the following files:

  • OriginalFile.docx and UpdatedXMP.docx – text versions of the XMP before and after the update.
  • MissingNamespaces.docx – a list of namespaces missing in the updated XMP. Take note that this was extracted from csv file so expect a different format but the important here is the namespace
    MissingNamespaces.docx (15.0 KB)

UpdatedXMP.docx (17.4 KB)

OrignalFile.docx (19.1 KB)

OriginalFile.jpg (174.0 KB)

UpdatedXMP.jpg (165.4 KB)

  • OriginalFile.jpg and UpdatedXMP.jpg – the image files from which the above XMP data was extracted.

Please review these attachments and advise on why the proprietary namespaces are being removed during the update.

Aspose.Imaging version 25.7.0

private void UpdateXmpMetadata(IUpdateXmpMetadataMediaAction action)
{
    using (var inputStream = System.IO.File.OpenRead(action.Path))
    using (var img = Image.Load(inputStream))
    {
        if ((_supportedTargetFormats.Contains(img.FileFormat) || Path.GetExtension(action.Path).ToLower() == ".jpg" || Path.GetExtension(action.Path).ToLower() == ".tif") && img is RasterImage && !String.IsNullOrEmpty(action.XmpMetadataMapping))
        {
            XDocument xmpMapping = XDocument.Parse(action.XmpMetadataMapping);

            // Getting the xmp metadata
            XmpPacketWrapper xmpData = ((RasterImage)img).XmpData;

            if (xmpData == null)
            {
                // Create xmp metadata if the image doesn't contains any xmp data.
                XmpHeaderPi xmpHeader = new XmpHeaderPi(Guid.NewGuid().ToString());
                XmpTrailerPi xmpTrailer = new XmpTrailerPi(true);
                XmpMeta xmpMeta = new XmpMeta();

                xmpData = new XmpPacketWrapper(xmpHeader, xmpTrailer, xmpMeta);
                ((RasterImage)img).XmpData = xmpData;
            }

            foreach (var mapping in xmpMapping.Descendants("xmpMapping").Elements("add"))
            {
                // Get values from xmp metadata mapping
                var xmpNamespace = mapping.Attribute("namespace").Value;
                var xmpName = mapping.Attribute("name").Value;
                var xmpPrefix = mapping.Attribute("prefix").Value;
                var xmpValue = mapping.Value;

                if (xmpData.ContainsPackage(xmpNamespace))
                {
                    // Xmp namespace exists
                    foreach (var xmpPackage in xmpData.Packages)
                    {
                        if (xmpPackage.NamespaceUri.Trim().ToLower() == xmpNamespace.Trim())
                        {
                            if (xmpPackage.ContainsKey(xmpPackage.Prefix + ":" + xmpName))
                            {
                                // Update xmp value if the property exists
                                xmpPackage[(xmpPackage.Prefix + ":" + xmpName)] = xmpValue;
                            }
                            else
                            {
                                // Create new property if it not exists
                                xmpPackage.AddValue(xmpPackage.Prefix + ":" + xmpName, xmpValue);
                            }

                        }
                    }
                }
                else
                {
                    // Create xmp namespace and xmp property if namespace not exists
                    XmpBasicPackage xmp = new XmpBasicPackage(xmpPrefix, xmpNamespace);
                    xmp.AddValue(xmpPrefix + ":" + xmpName, xmpValue);
                    xmpData.AddPackage(xmp);
                }
            }
        }

        using (var outputStream = new MemoryStream())
        {
            img.Save(outputStream);
            using (var fileStream = System.IO.File.Create(action.OutputPath))
            {
                outputStream.Seek(0, System.IO.SeekOrigin.Begin);
                outputStream.CopyTo(fileStream);
            }
        }
    }
}```

@3stan

It appears that your client is encountering issues with missing proprietary color profile namespaces after updating the XMP data in the image files. This may be related to how the XMP metadata is being processed during the update.

In your code, you are checking if the XMP namespace already exists before adding or updating properties. If the proprietary namespaces are not being recognized or are being removed, consider the following steps:

  1. Namespace Handling: Verify that the proprietary namespaces are correctly defined and included in the XMP mapping. If they are not part of the xmpMapping, they will not be preserved.

  2. XMP Data Initialization: When creating new XMP data, ensure that all necessary namespaces are included from the outset. If the original image does not contain these namespaces, they must be added explicitly.

  3. Debugging: Implement logging to track which namespaces are being processed and whether the proprietary ones are being skipped or removed during the update.

Here’s a code snippet to help ensure that proprietary namespaces are preserved:

foreach (var mapping in xmpMapping.Descendants("xmpMapping").Elements("add"))
{
    var xmpNamespace = mapping.Attribute("namespace").Value;
    // Log the processing of the namespace
    Console.WriteLine($"Processing namespace: {xmpNamespace}");

    // Existing logic...
}

This logging will assist in identifying if the proprietary namespaces are being processed correctly. If they remain missing after these checks, consider reaching out to Aspose support with detailed logs for further assistance.

If you have any further questions or require more specific guidance, please feel free to ask!

@3stan Thank you for your interest in our product. We are investigating this issue and will inform you of the results as soon as possible.

@3stan We have checked the file OriginalFile.jpg using various methods, tools, and online services, but none of them were able to extract the data you described. Please provide additional information — how exactly did you obtain the list of XMP data contained in the file, and could the file OriginalFile.jpg have been modified by any third-party software? Also, please attach the original image once again, archived in a ZIP file.

@Alexey.Karpenko

The Tool that I’ve used is IrfranView. You can check the XMP under IPTC information

image.jpg (157.8 KB)

Here are the files both the original file and the updated xmp via Aspose.
Sample Files

No, there is no third party used to edit the original file.

@3stan
Thank you for providing the additional information.
Our team found out the reasons of the issue.
The according task will be created.

@3stan
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): IMAGINGNET-7865

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@evgeniy.sidenko

Can you provide us tentative release for the fix? Please understand that we also need to update our customer on our end. Thanks

I will give you the answer today

@3stan
This task will be implemented within the next month, and since the set of tasks for the next release has already been determined, this issue’s fix will be included in release 26.2, and will be available in early February of the following 2026.

As a rule, hot-fix releases are not released, except for releases with the elimination of security-related errors.

If you have purchased a license or paid for paid support, please contact the paid support resource.
If we receive a command from there, we will consider the possibility of releasing a hot-fix version for you.

We are sorry that you have encountered this problem.