我认为正如建议的那样,这是.net的差异。不是 IIS。
只需重新编写您的代码,您就可以节省很多时间,非常简单的事情。
这是我不久前编写的一个图像处理程序,它可以将任何图像重新绘制到您的设置中。
public class image_handler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
// set file
string ImageToDraw = context.Request.QueryString["FilePath"];
ImageToDraw = context.Server.MapPath(ImageToDraw);
// Grab images to work on's true width and height
Image ImageFromFile = Image.FromFile(ImageToDraw);
double ImageFromFileWidth = ImageFromFile.Width;
double ImageFromFileHeight = ImageFromFile.Height;
ImageFromFile.Dispose();
// Get required width and work out new dimensions
double NewHeightRequired = 230;
if (context.Request.QueryString["imageHeight"] != null)
NewHeightRequired = Convert.ToDouble(context.Request.QueryString["imageHeight"]);
double DivTotal = (ImageFromFileHeight / NewHeightRequired);
double NewWidthValue = (ImageFromFileWidth / DivTotal);
double NewHeightVale = (ImageFromFileHeight / DivTotal);
NewWidthValue = ImageFromFileWidth / (ImageFromFileWidth / NewWidthValue);
NewHeightVale = ImageFromFileHeight / (ImageFromFileHeight / NewHeightVale);
// Set new width, height
int x = Convert.ToInt16(NewWidthValue);
int y = Convert.ToInt16(NewHeightVale);
Bitmap image = new Bitmap(x, y);
Graphics g = Graphics.FromImage(image);
Image thumbnail = Image.FromFile(ImageToDraw);
// Quality Control
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.SmoothingMode = SmoothingMode.HighQuality;
g.PixelOffsetMode = PixelOffsetMode.HighQuality;
g.CompositingQuality = CompositingQuality.HighQuality;
g.DrawImage(thumbnail, 0, 0, x, y);
g.Dispose();
image.Save(context.Response.OutputStream, ImageFormat.Jpeg);
image.Dispose();
}
public bool IsReusable
{
get
{
return true;
}
}