JPEG Conversion CorruptOrDamagedFileException with empty RDF

Hello,

We investigated a JPEG document info failure involving an XMP packet containing an empty <rdf:RDF/> element. These are typically found to be files created with a phone camera.

The affected JPEGs display correctly in image viewers, but GroupDocs fails during GetDocumentInfo() with:

GroupDocs.Conversion.Exceptions.CorruptOrDamagedFileException:
Cannot convert. The file is corrupt or damaged. Image loading failed.

Inner exception: Aspose.Imaging.CoreExceptions.ImageLoadException
Root exception: System.NullReferenceException
Object reference not set to an instance of an object.

Version comparison

Testing the same synthetic JPEG bytes produced these results:

GroupDocs.Conversion for .NET Result
26.6.0 Successful conversion
26.7.0 Fails
26.8.0 Fails
26.10.0 Fails

The failing JPEG contains a standard XMP APP1 packet with an empty RDF container:

<x:xmpmeta xmlns:x="adobe:ns:meta/">
  <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"/>
</x:xmpmeta>

A matching control image converts successfully when the RDF contains an empty Description:

<x:xmpmeta xmlns:x="adobe:ns:meta/">
  <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
    <rdf:Description rdf:about=""/>
  </rdf:RDF>
</x:xmpmeta>

Investigation findings

  • Removing only the empty XMP APP1 packet allows conversion to succeed, without re-encoding or changing the remaining JPEG bytes.
  • An empty <rdf:Description/> succeeds despite containing no metadata properties, suggesting the failure relates to the missing Description element rather than the absence of property values.

Reproduction

I tried uploading a JPEG with an empty RDF, but it did not like that I also uploaded a JPEG that works - every time I try to upload the empty RDF file it shows and downloads as the working JPEG. So I have removed the attachments.

using GroupDocs.Conversion;
using GroupDocs.Conversion.Options.Convert;

using var converter =
    new Converter("empty-rdf.jpg");

// Throws CorruptOrDamagedFileException with an underlying NullReferenceException.
converter.GetDocumentInfo();

converter.Convert("output.pdf", new PdfConvertOptions());

Hello @clancy.bird,

Thank you for the detailed investigation. It made this easy to pin down.

We created a synthetic JPEG with the same empty rdf:RDF/ XMP packet and reproduced the issue on our side. GetDocumentInfo() throws CorruptOrDamagedFileException with the inner NullReferenceException in 26.7.0 and later versions, including 26.10.0, while 26.6.0 handles the same file fine. The control files behave just as you described: an empty rdf:Description inside rdf:RDF, or no XMP packet at all, loads without problems.

We have logged this in our tracking system under the ID CONVERSIONNET-8740. Until it’s fixed, stripping the empty XMP APP1 segment before passing the file to the converter (as you already found) is a safe workaround, since it doesn’t touch the image data.

We’ll update this thread as soon as we have any news to share.