-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Closed
Labels
Milestone
Description
Tried using System.Drawing.Common package for my .net core web api project. It runs fine under windows but on ubunto (which is my host server), it throws following errors:
This is the method i used to generate thumbnail:
public static bool CreateThumbnail(int Width, int Height, Stream filePath, string saveFilePath)
{
try
{
var byteArray = filePath;
var streamImg = Image.FromStream(byteArray);
Bitmap sourceImage = new Bitmap(streamImg);
using (Bitmap objBitmap = new Bitmap(Width, Height))
{
objBitmap.SetResolution(sourceImage.HorizontalResolution, sourceImage.VerticalResolution);
using (Graphics objGraphics = Graphics.FromImage(objBitmap))
{
// Set the graphic format for better result cropping
objGraphics.SmoothingMode = SmoothingMode.HighQuality;
objGraphics.PixelOffsetMode = PixelOffsetMode.HighSpeed;
objGraphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
objGraphics.CompositingQuality = CompositingQuality.HighQuality;
objGraphics.DrawImage(sourceImage, 0, 0, Width, Height);
// Save the file path, note we use png format to support png file
objBitmap.Save(saveFilePath);
}
}
}
catch (Exception ex)
{
LogHelper.Log("Create Thumbnail: ERROR:" + ex.Message + "\n" + ex.StackTrace);
return false;
}
return true;
}
ERROR:The type initializer for 'Gdip' threw an exception.
at System.Drawing.SafeNativeMethods.Gdip.GdipLoadImageFromDelegate_linux(StreamGetHeaderDelegate getHeader, StreamGetBytesDelegate getBytes, StreamPutBytesDelegate putBytes, StreamSeekDelegate doSeek, StreamCloseDelegate close, StreamSizeDelegate size, IntPtr& image)
at System.Drawing.Image.InitFromStream(Stream stream)
at System.Drawing.Image.LoadFromStream(Stream stream, Boolean keepAlive)
Already installed
sudo apt-get install libgdiplus
and did this too:
cd /usr/lib
sudo ln -s libgdiplus.so gdiplus.dll
So Any workaround or thoughts on this?
Reactions are currently unavailable