1

好的,我有这个脚本,目前图像 URL 是正确的,因为它使用链接加载。但是我收到了这篇文章主题中显示的错误。

这是完整的错误:

Server Error in '/' Application.

Parameter is not valid.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.ArgumentException: Parameter is not valid.

Source Error: 


Line 33:        {
Line 34:            //Rotate clockwise
Line 35:            img.RotateFlip(RotateFlipType.Rotate90FlipNone);
Line 36:        } else if (rotate_dir == "anticlockwise")
Line 37:        {

Source File: c:\inetpub\wwwroot\nightclub_photography\net\rotate_script.aspx    Line: 35 

Stack Trace: 


[ArgumentException: Parameter is not valid.]
   System.Drawing.Image.RotateFlip(RotateFlipType rotateFlipType) +618911
   ASP.nightclub_photography_net_rotate_script_aspx.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\nightclub_photography\net\rotate_script.aspx:35
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +25
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +42
   System.Web.UI.Control.OnLoad(EventArgs e) +132
   System.Web.UI.Control.LoadRecursive() +66
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2428

Version Information: Microsoft .NET Framework Version:2.0.50727.5472; ASP.NET Version:2.0.50727.5459

这是代码。除了旋转图像之外,这一切都很好。

<%@ Page Language="C#" Debug="true" %>
    <%@ Import Namespace="System" %>
    <%@ Import Namespace="System.Drawing" %>
    <%@ Import Namespace="System.Web" %>

    <script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
        //string url = Request.QueryString["url"];
        string urlStart = @"C:/inetpub/wwwroot/nightclub_photography/data/images/";

        //Rotation direction
        string rotate_dir = Request.QueryString["dir"];

        //Image locations
        string str = Request.QueryString["t"];
        string[] locs = str.Split(',');

        foreach (string item in locs)
        {
            string url = urlStart + item;

            Response.Write(url+"<br />");

            //create an image object from the image in that path
            System.Drawing.Image tmp = System.Drawing.Image.FromFile(url);
            System.Drawing.Image img = tmp;

            tmp.Dispose();

            //Rotate the image in memory
        if (rotate_dir == "clockwise")
        {
            //Rotate clockwise
            img.RotateFlip(RotateFlipType.Rotate90FlipNone);
        } else if (rotate_dir == "anticlockwise")
        {
            //Rotate anti-clockwise
            img.RotateFlip(RotateFlipType.Rotate90FlipXY);
        }

        //Delete the file so the new image can be saved
        System.IO.File.Delete(url);

        //save the image to the file
        img.Save(url);

        //release image file
        img.Dispose();
    }
}
</script>

如果我要删除 Response.Write 下面的代码,脚本将生成以下内容,这证明 URL 是正确的。

C:/inetpub/wwwroot/nightclub_photography/data/images/13082013/0/1016158_560614047310285_366565184_n.jpg
C:/inetpub/wwwroot/nightclub_photography/data/images/13082013/0/431824_542683245770032_1870555927_n.jpg
4

0 回答 0