We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Corrupted Tif file after UpdateXmpMetadataMediaAction

I uploaded a tif file and downloaded using UpdateXmpMetadataMediaAction. The action is success but the file is corrupted. I tried with aspose.imaging versions 22.8, 22.9 and latest 22.10 but still the file is corrupted. I can send you the image but it cannot attach tif file here. Please check. Thank you.

@asiman please provide for us code that you use to reproduce and file. You can try attach file in zipped archive in post or upload to file service like dropbox, google drive, one drive etc.

Pictures.zip (4.8 MB)
Attached are the tif files. Filename original is the uploaded tif file and filename corrupted is the downloaded after UpdateXmpMetadataAction.

@asiman also please provide for us code that you use to reproduce issue.

Code_Tif_UpdateXmpMetadata.zip (2.1 KB)
Here’s the code

To add, the file is corrupted when UpdateXmpMetada

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;
                                    // Create new property if it not exists
                                    xmpPackage.AddValue(xmpPackage.Prefix + ":" + xmpName, xmpValue);

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

@asiman, we have reviewed your code and looks your xmp commands are typical and does not contain errors (we don’t have your value of action.XmpMetadataMapping). And we found that issue reported by you is not related to xmp, but presented tiff image is saved wrongly. To avoid this you can try save in another color mode, for example: tiff.Save(@“result.tif”, new TiffOptions(Aspose.Imaging.FileFormats.Tiff.Enums.TiffExpectedFormat.TiffDeflateRgb)); Related to this bug we prepared ticket to fix it - IMAGINGNET-5875

@samer.el-khatib4aspose This is the XmpMetadataMapping we used:

  <add namespace="http://purl.org/dc/elements/1.1/" prefix="dc" name="description"><![CDATA[
<ref:text out="&lt;rdf:Alt xmlns:rdf=&quot;http://www.w3.org/1999/02/22-rdf-syntax-ns#&quot;&gt;"/>
<ref:text out="&lt;rdf:li xml:lang=&quot;x-default&quot;&gt;"/>
<ref:record fieldName="EmbeddedDescription" out="value"/>
<ref:text out="&lt;/rdf:li&gt;&lt;rdf:Alt&gt;"/>

The original tif file provided by customer is in CMYK color mode that’s why we are not saving it as Rgb color mode. We also tried creating a tif file with RGB color mode and it is working.
For the ticket IMAGINGNET-5875 you provided, is this will fix the tif file with non RGB color mode (e.g. CMYK)? As I need to inform the solution for this bug.

@asiman, in IMAGINGNET-5875 we are going to investigate and fix issue with provided file, exactly we don’t know what it will require from us.

@samer.el-khatib4aspose May I ask what is the current status for this bug fix task IMAGINGNET-5875 is? This is a problem for our customers that we would like to resolve which not changing the original color mode. Thanks

@asiman This issue is not fixed yet, it is in the queue. You will be notified on completion.