C# Image.FromStream is working in windows(Azure) but not woring in Linus(GCP)

SubramanianUdayakumar-4815 20 Reputation points
2021-08-16T17:28:58.897+00:00

Hi Team,

  This is my piece of code, here the first line of code (var thumbImage = Image.FromStream(image.OpenReadStream());) is working in windows(Azure) but it's not working in Linux(GCP). Could you please provide any alternative solution to work in Linux platform.

Here image type is "IFormFile image"

var thumbImage = Image.FromStream(image.OpenReadStream());
var thumb = thumbImage.GetThumbnailImage(120, 120, () => false, IntPtr.Zero);

Thanks
Udayakumar S

Developer technologies ASP.NET ASP.NET Core
0 comments No comments
{count} votes

Accepted answer
  1. Anonymous
    2021-08-17T01:41:09.847+00:00

    Hi @Udayakumar S,

    Please check this article, to make use of the System.Drawing.Common NuGet package, you'll need to ensure some additional dependencies are installed in your Docker container for both Linux and Windows.

    For Linux, it's just a matter of installing a few extra packages in your Dockerfile:

    Debian/Ubuntu:

    # install System.Drawing native dependencies  
    RUN apt-get update \  
        && apt-get install -y --allow-unauthenticated \  
            libc6-dev \  
            libgdiplus \  
            libx11-dev \  
         && rm -rf /var/lib/apt/lists/*  
    

    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best regards,
    Dillion

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. SubramanianUdayakumar-4815 20 Reputation points
    2021-08-18T17:25:27.967+00:00

    Thanks ZhiLv-MSFT. This solution is working fine for me. Thanks a lot


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.