Aspose.Imaging exception "imaging loading failed" when converting heic to pdf

Getting the following exception when trying to load an heic file into Aspose.Imaging version 25.10 before saving to pdf. I have attached a sample file.

Aspose.Imaging.CoreExceptions.ImageLoadException
  HResult=0x80131500
  Message=Image loading failed.
  Source=Aspose.Imaging
  StackTrace:
   at Aspose.Imaging.Image.#=z5JWA_Z$A$9XR(StreamContainer #=zFY$Jfp$lhZrh, LoadOptions #=z6M65tOh0hoYb, #=zSDPvV3YaRdiB9siH6H2$QAQIsk2$wh9x5qHI7mU= #=zn5$qHPk=)
   at Aspose.Imaging.Image.Load(String filePath)
   at RevealIndexClientService.Application.UseCases.DocumentConversion.NativeView.NativeViewDocumentConverterAsposeHeic.<Convert>d__1.MoveNext() in G:\Reveal\Repositories\rent-18435-aspose-svg-pdf\Development\Reveal Services\RevealIndexClientService\RevealIndexClientService\Application\UseCases\DocumentConversion\NativeView\NativeViewDocumentConverterAsposeHeic.cs:line 35

  This exception was originally thrown at this call stack:
    System.ThrowHelper.ThrowKeyNotFoundException<T>(T) in ThrowHelper.cs
    System.Collections.Generic.Dictionary<TKey, TValue>.this[TKey].get(TKey) in Dictionary.cs
    Openize.Heic.Decoder.HeicImageFrame.LoadProperties(Openize.Heic.Decoder.IO.BitStreamWithNalSupport, System.Collections.Generic.List<Openize.IsoBmff.Box>)
    Openize.Heic.Decoder.HeicImageFrame.HeicImageFrame(Openize.Heic.Decoder.IO.BitStreamWithNalSupport, Openize.Heic.Decoder.HeicImage, uint, System.Collections.Generic.List<Openize.IsoBmff.Box>)
    Openize.Heic.Decoder.HeicImage.ReadFramesMeta(Openize.Heic.Decoder.IO.BitStreamWithNalSupport)
    Openize.Heic.Decoder.HeicImage.HeicImage(Openize.Heic.Decoder.HeicHeader, Openize.Heic.Decoder.IO.BitStreamWithNalSupport)
    Openize.Heic.Decoder.HeicImage.Load(System.IO.Stream)
    Aspose.Imaging.HEIC.Adapter.HEICImage.HEICImage(System.IO.Stream)
    Aspose.Imaging.HEIC.Adapter.Loader.HEICImageLoader.Load(Aspose.Imaging.StreamContainer, Aspose.Imaging.LoadOptions)
    Aspose.Imaging.Image.#=z5JWA_Z$A$9XR(Aspose.Imaging.StreamContainer, Aspose.Imaging.LoadOptions, #=zSDPvV3YaRdiB9siH6H2$QAQIsk2$wh9x5qHI7mU=)

Inner Exception 1:
KeyNotFoundException: The given key '122' was not present in the dictionary.

PROD_0000160.zip (2.4 MB)

@skowald

The “Image loading failed” exception you are encountering when converting HEIC to PDF using Aspose.Imaging may be due to an unsupported HEIC file format or a corrupted file. Here are a few steps you can take to troubleshoot and resolve the issue:

  1. Check File Integrity: Ensure that the HEIC file is not corrupted. Try opening it with a different application to verify its integrity.

  2. Update Aspose.Imaging: Make sure you are using the latest version of Aspose.Imaging, as updates may include fixes for known issues with file formats.

  3. Convert to Supported Format: If the HEIC file continues to cause issues, consider converting it to a more common format (like JPEG or PNG) using a different tool before processing it with Aspose.Imaging.

  4. Sample Code: Here’s a basic example of how to load a HEIC file and save it as a PDF:

    using Aspose.Imaging;
    using Aspose.Imaging.ImageOptions;
    
    // Load the HEIC file
    using (Image image = Image.Load("path/to/your/file.heic"))
    {
        // Save as PDF
        image.Save("output.pdf", new PdfOptions());
    }
    

If the problem persists after trying these steps, please provide additional details about the HEIC file or any error messages you receive for further assistance.

I’m using Aspose.Imaging 25.10 and that example code is exactly what I’m using. Can it be confirmed that this heic is not supported? I’m using Aspose so that I do not have to use another tool to convert to jpeg. Thanks!

Hi @skowald
We appreciate your interest in Aspose.Imaging.
We are sorry that you have faced with such a problem. We are going to check it out ASAP.