.NET 3.5 web application - C # image scaling on the fly - lower quality on deployed site or development

I have an MVC.NET application focused on VS 2008, .NET 3.5. I am developing Windows 7 with its IIS, but deploying to a Windows Server 2003 environment with .NET 3.5 SP1 installed.

We have an image scaling action that returns the image from the database in the requested resolution and converts to PNG on the fly using the System.Drawing and System.Drawing.Imaging APIs.

The image uploaded through the expanded site is 1/2 the size / quality of the one under development. The original image is identical, but a request through a deployed website leads to 6.15 kb 154x200 PNG, but during development, it leads to 12.28 kb 154x200 PNG.

My suspicion is there any difference in the .NET graphics lib on 3.5 SP1 on a Windows server? My application is explicitly intended for the .NET 3.5 runtime.

      Image image = Image.FromStream(new MemoryStream(document.content));
      MemoryStream memStream = new MemoryStream();
      Bitmap bmp = new Bitmap(image, (int)width, (int)height);
      ImageFormat format = ImageFormat.Png;
      string mimeType = document.mimeType;
      if(document.mimeType == "image/png")
          ; // format = ImageFormat.Png;
      else if (document.mimeType == "image/jpeg")
         format = ImageFormat.Jpeg;
      else if (document.mimeType == "image/gif")
         format = ImageFormat.Gif;
      else if (document.mimeType == "image/tiff")
      {
         format = ImageFormat.Png; // convert tiff to png
         mimeType = "image/png";
      }

      bmp.Save(memStream, format);

HTTP headers: Development: Cache-Control private Content-Type image / png Server Microsoft-IIS / 7.5 X-AspNetMvc-version 2.0 X-AspNet-version 2.0.50727 X-Powered-By ASP.NET Date Fri, 05 Mar 2010 19:59:50 GMT Content Length 12574

Production: Fri Fri 05 Mar 2010 20:02:58 GMT Microsoft-IIS / 6.0 server X-Powered-By ASP.NET X-AspNet version 2.0.50727 X-AspNetMvc version 2.0 Cache-Control private Content-Type image / png Content-Length 6514

+3
source share
2 answers

, , , . , .

, . ( 180 ..NET .)

0

Source: https://habr.com/ru/post/1735640/


All Articles