image-processingazure-blob-storageimageresizerazure-functions

Image Resizer issue with Azure Functions


I've been following a tutorial on how to resize images using ImageResizer listening to blob storage triggers in Azure Functions. However, i'm getting the following error message:

error CS0246: The type or namespace name 'ImageResizer' could not be found (are you missing a using directive or an assembly reference?)

error CS0246: The type or namespace name 'ImageResizer' could not be found (are you missing a using directive or an assembly reference?)

error CS0103: The name 'ImageResizer' does not exist in the current context

My project.json config has been set up as follows:

{
"frameworks": {
  "net46":{
    "dependencies": {
      "ImageResizer": "4.0.5"
    }
  }
 }
}

and my run code is:

#r "System.Drawing"
#r "System.Web"

using ImageResizer;
using System.Drawing;
using System.Drawing.Imaging;

public static void Run(Stream inputImage, string imageName, Stream outputImage, TraceWriter log)
{
    log.Info($"C# Blob trigger function Processed blob\n Name:{imageName} \n Size: {inputImage.Length} Bytes");

    var settings = new ImageResizer.ResizeSettings{
        MaxWidth = 400,
        Format = "jpg"
    };

    ImageResizer.ImageBuilder.Current.Build(inputImage, outputImage, settings);

}

Solution

  • I managed to resolve the issue in the end. The problem was, that i had actually called the name of my function 'ImageReizer', which creates a folder with that name in the App Service Plan in the back-end. The problem was, that because it had the same name as the NugetPackage 'ImageResizer', it was getting confused and looking in the project folder instead of the package folder of the same name.

    I rebuilt the function with a different name (ImageManipulation) and everything now works as expected.