We have a thumbnail generator lambda function which I\'m trying to update to .NET Core 2.0, but I\'ve encountered the following error when using Microsoft\'s System.Dr
I had the same issue after uploading my application on Ubuntu 18 server running dotnet core 2.1.500 version. I resolved this issue with this solution https://github.com/dotnet/dotnet-docker/issues/618 using MichaelSimons suggestions.
I ran
#sudo apt-get update
#sudo apt-get install -y --allow-unauthenticated \
libc6-dev \
libgdiplus \
libx11-dev \
#sudo rm -rf /var/lib/apt/lists/*
This resolved the issues.
I found a solution for this issue which worked for me:
At first i removed the System.Drawing.Common library from the project, then i installed the library you can find here. It uses the same classes.
using System.Drawing
...
var bmp = new Bitmap(100,100);
At last I installed this other library which contains all the dll's necesary for using drawing libraries on Linux and Lambda as well. By doing this steps the code can be uploaded to AWS without any problem.
If one uses centOS, then below command helps.
For image processing in .NET Core Lambda I use the SixLabors.ImageSharp
Here is the code I used in my recent AWS re:Invent talk that did a log if image processing:
var imageBuffer = new MemoryStream();
var resizeOptions = new ResizeOptions
{
Size = new SixLabors.Primitives.Size { Width = this.TileSize, Height = this.TileSize},
Mode = ResizeMode.Stretch
};
image.Mutate(x => x.Resize(resizeOptions));
image.Save(imageBuffer, new SixLabors.ImageSharp.Formats.Jpeg.JpegEncoder());
imageBuffer.Position = 0;