0

I have tried to create an azure function (hosted in an azure function app) that create lower resolution .jpg files when a .nef (Nikon raw file) is uploaded to a blob container, and put them in separate containers. However, the resulting output is of very low quality. When I use ImageMagick locally, either through code or the CLI, it works perfectly well (except colors being a bit off).

Image before and after convertion and resample in the blob containers: https://ibb.co/s1dS3Wz

The following is the service class used for converting and resampling the image (just passed through DI and the streams are the input and output bindings of the function).

public class ImageResizer : IImageResizer
{
    public void Resize(Stream input, Stream output, int width, int height)
    {
        MagickGeometry smallSize = new MagickGeometry(width, height);

        input.Position = 0;
        var settings = new MagickReadSettings();
        settings.ColorSpace = ColorSpace.sRGB;
        settings.Density = new Density(300, 300, DensityUnit.PixelsPerInch);
        settings.Depth = 14;

        using (MagickImage image = new MagickImage(input, settings))
        {
            image.AutoOrient();
            image.Quality = 85;
            image.Format = MagickFormat.Jpg;
            image.Resize(smallSize);
            smallSize.IgnoreAspectRatio=false;
            image.Write(output);
        }
    }
}

Does anyone know why this is happening, and how I potentially could fix it?

BlackZoda
  • 1
  • 1

0 Answers0