Free Support Forum - aspose.com

Running under Azure Function


#1

Using .Net. We are having trouble getting Aspose.Imaging to run within an Azure Function. The error coming back is

Unable to find assembly ‘Aspose.Imaging, Version=19.4.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56’.

However all prior Aspose.Imaging class and method reference work until the .Save operation happens which is when we get the error. I suspect the issue is that the Aspose.Imaging is needed a dependency but have no idea what it would need. Example:

    JpegImage jpegImage = (JpegImage)image;
    jpegImage.AutoRotate();

    var resizeDimentions = SetResizeParameters(jpegImage.Height, jpegImage.Width, imageCompressRequest);
    if (resizeDimentions != null)
        jpegImage.Resize(resizeDimentions.Width, resizeDimentions.Height);

    var jpegOptions = new JpegOptions()
    {
        CompressionType = JpegCompressionMode.Progressive,
        Quality = GetJpegQuality(imageCompressRequest.CompressionLevel)
    };

    var resultStream = new MemoryStream();
    jpegImage.Save(resultStream, jpegOptions);

    return resultStream.ToArray();

The error happens on the jpegImage.Save operation. The stack trace we get is below. Do note this does not happen if the exact same code runs in say class in a ASP.Net or command line setting.

   at Aspose.Imaging.Image.Save(Stream stream, ImageOptionsBase optionsBase, Rectangle boundsRectangle)
   at Aspose.Imaging.Image.Save(Stream stream, ImageOptionsBase optionsBase)
   at nkf.Integration.ImageProcessing.Function.Services.ImageAsposeCompressService.<CompressJpeg>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at nkf.Integration.ImageProcessing.Function.Services.ImageAsposeCompressService.<Compress>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at nkf.Integration.ImageProcessing.Functions.Compress.<Run>d__0.MoveNext()

#2

@fhamandi,

Can you please share source file so that we may further investigate to help you out. Also please share complete environment details with us.


#3

Attached is the example project (.Net native 4.7.2)
nkf.Integration.ImageProcessing.zip (69.9 KB)


#4

@fhamandi,

I have observed the issue shared by you and have created an issue with ID IMAGINGNET-3425 in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.