Convert Image to WebP using ImageProcessor

2k Views Asked by At

I used this code to convert uploaded images to WebP format in asp.net core:

        using (var webPFileStream = new FileStream(webpImagePath, FileMode.Create))
        {                
            using (var imageFactory = new ImageFactory(preserveExifData: false))
            {
                imageFactory.Load(file.OpenReadStream())
                            .Format(new WebPFormat())
                            .Quality(100)
                            .Save(webPFileStream);
            }
        }

It works fine locally. But after hosting, it gives me error message "cannot load libwebp.dll". I couldn't find any solution on stackoverflow and couldn't figure if it's the host or the package.

1

There are 1 best solutions below

2
Brando Zhang On

According this article, please make sure you have installed below things.

Requires msvcr120.dll from the Visual C++ Redistributable Package for Visual Studio 2013 to be installed on the server.

If you are using version 1.0.2 or lower it instead requires msvcr110.dll from the Visual C++ Redistributable Package for Visual Studio 2012 to be installed.