.NET 3.5的Web应用程序 - 在飞行的C#图像缩放 - 上部署的站点VS开发质量下降缩放、应用程序、图像、站点

2023-09-05 02:27:45 作者:只是回忆在作祟

我有一个VS 2008,.NET 3.5的目标MVC.NET应用程序。我开发的Windows 7与它的IIS,但部署到Windows Server 2003环境中安装了.NET 3.5 SP1。

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

我们有一个图像缩放动作,返回从要求的分辨率数据库中的图像,并转换成PNG在与System.Drawing中和System.Drawing.Imaging的API飞。

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

图片通过部署的站点提供了1/2的一家以开发的尺寸/质量。源图像是相同的,但通过部署的站点导致的154x200 6.35 KB PNG要求,但对开发它导致的154x200一个12.28 KB PNG。

The image served up via the deployed site is 1/2 the size/quality of the one in development. The source image is identical, but requesting via the deployed site results in a 6.35 kb PNG of 154x200, but on development it results in a 12.28 kb PNG of 154x200.

我的怀疑是有3.5 SP1的Windows服务器上的.NET图形的lib有些区别?我的应用程序明确面向.NET 3.5运行时。

My suspicion is there is some difference in the .NET graphics lib on 3.5 SP1 on Windows server? My app explicitly targets 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标头是:  发展:   缓存控制私人   内容类型图像/ PNG   服务器Microsoft-IIS / 7.5   的X AspNetMvc-2.0版   的X ASPNET-版本2.0.50727   的X技术支持,通过ASP.NET   日期星期五,2010十九点五十九分50秒格林尼治标准​​时间03月05日   内容长度12574

HTTP headers are: 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

制作:   日期星期五,2010 20时〇二分58秒格林尼治标准​​时间03月05日   服务器Microsoft-IIS / 6.0   的X技术支持,通过ASP.NET   的X ASPNET-版本2.0.50727   的X AspNetMvc-2.0版   缓存控制私人   内容类型图像/ PNG   内容长度6514

Production: Date Fri, 05 Mar 2010 20:02:58 GMT Server Microsoft-IIS/6.0 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

推荐答案

也许你需要设置你仅仅使用默认值的像素格式或其它选项:的 HTTP://www.$c$cproject.com/KB/GDI-plus/imageresize.aspx

Maybe you need to set the pixel format or other options that you're just using the default value for: http://www.codeproject.com/KB/GDI-plus/imageresize.aspx

 
精彩推荐
图片推荐