How to rotate image upon upload?

Discussion in 'ASP .Net' started by Showjumper, Feb 13, 2004.

  1. Showjumper

    Showjumper Guest

    Hi,
    I have developed an upload server controls to be reused over a number of
    projects. One of the tasks it needs to handle is to rotate an image. I want
    to accoplish this by checking the checkbox that is next to the file field.
    Once i browse for the file, i check the box to rotate and then upload.
    However i am unable to get it to rotate when the box is checked. It only
    rotates when i set a boolean (RotateImage) to true. Any ideas on how to go
    about rotating by checking the box.?

    Also, another question with respect to GDI+ - can i take existing image
    (like a gif) and then stamp it on to another image - like a copyright
    symbol.
     
    Showjumper, Feb 13, 2004
    #1
    1. Advertising

  2. Showjumper

    Teemu Keiski Guest

    Hi,

    see these GDI articles by Chris Garrett
    http://authors.aspalliance.com/chrisg/default.asp?category=9

    --
    Teemu Keiski
    MCP, Microsoft MVP (ASP.NET), AspInsiders member
    ASP.NET Forum Moderator, AspAlliance Columnist

    "Showjumper" <> wrote in message
    news:...
    Hi,
    I have developed an upload server controls to be reused over a number of
    projects. One of the tasks it needs to handle is to rotate an image. I want
    to accoplish this by checking the checkbox that is next to the file field.
    Once i browse for the file, i check the box to rotate and then upload.
    However i am unable to get it to rotate when the box is checked. It only
    rotates when i set a boolean (RotateImage) to true. Any ideas on how to go
    about rotating by checking the box.?

    Also, another question with respect to GDI+ - can i take existing image
    (like a gif) and then stamp it on to another image - like a copyright
    symbol.
     
    Teemu Keiski, Feb 14, 2004
    #2
    1. Advertising

  3. Showjumper

    Showjumper Guest

    I had already been through those articles. I know how to rotate the image -
    it rotates just fine if a boolean is set in the properties panel. What i
    want to do is have it rotate if the checkbox is checked - the checkbox is
    next to the file field in the browser. Thats where my problem lies.
    "Teemu Keiski" <> wrote in message
    news:...
    > Hi,
    >
    > see these GDI articles by Chris Garrett
    > http://authors.aspalliance.com/chrisg/default.asp?category=9
    >
    > --
    > Teemu Keiski
    > MCP, Microsoft MVP (ASP.NET), AspInsiders member
    > ASP.NET Forum Moderator, AspAlliance Columnist
    >
    > "Showjumper" <> wrote in message
    > news:...
    > Hi,
    > I have developed an upload server controls to be reused over a number of
    > projects. One of the tasks it needs to handle is to rotate an image. I

    want
    > to accoplish this by checking the checkbox that is next to the file field.
    > Once i browse for the file, i check the box to rotate and then upload.
    > However i am unable to get it to rotate when the box is checked. It only
    > rotates when i set a boolean (RotateImage) to true. Any ideas on how to go
    > about rotating by checking the box.?
    >
    > Also, another question with respect to GDI+ - can i take existing image
    > (like a gif) and then stamp it on to another image - like a copyright
    > symbol.
    >
    >
    >
    >
     
    Showjumper, Feb 14, 2004
    #3
  4. Showjumper

    Teemu Keiski Guest

    Ok, sorry for that. So you mean you can't read the CheckBox's Checked
    property while uploading the image?

    --
    Teemu Keiski
    MCP, Microsoft MVP (ASP.NET), AspInsiders member
    ASP.NET Forum Moderator, AspAlliance Columnist


    "Showjumper" <> wrote in message
    news:...
    I had already been through those articles. I know how to rotate the image -
    it rotates just fine if a boolean is set in the properties panel. What i
    want to do is have it rotate if the checkbox is checked - the checkbox is
    next to the file field in the browser. Thats where my problem lies.
    "Teemu Keiski" <> wrote in message
    news:...
    > Hi,
    >
    > see these GDI articles by Chris Garrett
    > http://authors.aspalliance.com/chrisg/default.asp?category=9
    >
    > --
    > Teemu Keiski
    > MCP, Microsoft MVP (ASP.NET), AspInsiders member
    > ASP.NET Forum Moderator, AspAlliance Columnist
    >
    > "Showjumper" <> wrote in message
    > news:...
    > Hi,
    > I have developed an upload server controls to be reused over a number of
    > projects. One of the tasks it needs to handle is to rotate an image. I

    want
    > to accoplish this by checking the checkbox that is next to the file field.
    > Once i browse for the file, i check the box to rotate and then upload.
    > However i am unable to get it to rotate when the box is checked. It only
    > rotates when i set a boolean (RotateImage) to true. Any ideas on how to go
    > about rotating by checking the box.?
    >
    > Also, another question with respect to GDI+ - can i take existing image
    > (like a gif) and then stamp it on to another image - like a copyright
    > symbol.
    >
    >
    >
    >
     
    Teemu Keiski, Feb 14, 2004
    #4
  5. Showjumper

    Showjumper Guest

    Right. This is a server control, btw. Not sure if it makes a difference. I
    have the following in upload routine:
    If RotateCheck.Checked = True Then
    RotateImages()
    End If
    And in the createchildcontrols i have
    AddHandler btnButton.Click, AddressOf SaveImages

    The rotate only works if a boolean is set to tru in the property window, not
    if the checkbo is checked. Maybe i am missing something obvious.
     
    Showjumper, Feb 14, 2004
    #5
  6. Showjumper

    Teemu Keiski Guest

    Ok,

    can you post more complete set of code?

    --
    Teemu Keiski
    MCP, Microsoft MVP (ASP.NET), AspInsiders member
    ASP.NET Forum Moderator, AspAlliance Columnist

    "Showjumper" <> wrote in message
    news:...
    Right. This is a server control, btw. Not sure if it makes a difference. I
    have the following in upload routine:
    If RotateCheck.Checked = True Then
    RotateImages()
    End If
    And in the createchildcontrols i have
    AddHandler btnButton.Click, AddressOf SaveImages

    The rotate only works if a boolean is set to tru in the property window, not
    if the checkbo is checked. Maybe i am missing something obvious.
     
    Teemu Keiski, Feb 15, 2004
    #6
  7. Showjumper

    Showjumper Guest

    Here you go. If you need more let me know.

    Private Function RotateImage(ByVal SourceImage As String, ByVal DestImage As
    String) As Boolean
    Dim g As System.Drawing.Image
    g = System.Drawing.Image.FromFile(SourceImage)
    g.RotateFlip(System.Drawing.RotateFlipType.Rotate90FlipNone)
    g.Save(DestImage)
    g.Dispose()
    g = Nothing
    End Function

    'My call to function
    If RotateCheck.Checked = True Then
    RotateImage(context.Server.MapPath(_UploadDirectory & "\") + _fileName,
    context.Server.MapPath(_UploadDirectory & "\") + _fileName)
    End If

    Protected Overrides Sub CreateChildControls()
    ' Add File Fields
    Me.Controls.Add(New LiteralControl("<div align=""" & _align & """ "))
    For I = 1 To _NumberFileFields
    FileField = New HtmlControls.HtmlInputFile
    RotateCheck = New CheckBox
    Me.Controls.Add(New LiteralControl("<p>"))
    Me.Controls.Add(FileField)
    FileField.Size = _FileFieldSize
    FileField.Attributes.Add("class", _FileFieldCssClass)
    Me.Controls.Add(RotateCheck)
    Me.Controls.Add(New LiteralControl("</p>"))
    Next
    ' Add Submit Button
    btnButton.Text = _ButtonText
    btnButton.CssClass = _SubmitButtonCssClass
    AddHandler btnButton.Click, AddressOf SaveImages
    Me.Controls.Add(btnButton)
    'Add message
    Me.Controls.Add(New LiteralControl("<p class=""" & _UploadMsgCssClass &
    """>"))
    Me.Controls.Add(label1)
    Me.Controls.Add(New LiteralControl("</div>"))
    End Sub
     
    Showjumper, Feb 15, 2004
    #7
  8. Showjumper

    Showjumper Guest

    I know what the problem is. It works fine if it is only one checkbox on the
    page. However i am wanting a checkbox next to each file field to allow each
    image to be rotated independlty of the others or not at all. One checkbox on
    the page the image is rotated. But it also rotates images that dont need to
    be when multiple files are upped.
    "Teemu Keiski" <> wrote in message
    news:%...
    > Ok,
    >
    > can you post more complete set of code?
    >
    > --
    > Teemu Keiski
    > MCP, Microsoft MVP (ASP.NET), AspInsiders member
    > ASP.NET Forum Moderator, AspAlliance Columnist
    >
    > "Showjumper" <> wrote in message
    > news:...
    > Right. This is a server control, btw. Not sure if it makes a difference. I
    > have the following in upload routine:
    > If RotateCheck.Checked = True Then
    > RotateImages()
    > End If
    > And in the createchildcontrols i have
    > AddHandler btnButton.Click, AddressOf SaveImages
    >
    > The rotate only works if a boolean is set to tru in the property window,

    not
    > if the checkbo is checked. Maybe i am missing something obvious.
    >
    >
    >
    >
     
    Showjumper, Feb 16, 2004
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?QUNhdW50ZXI=?=

    Rotate ASP:Image 45 Degrees

    =?Utf-8?B?QUNhdW50ZXI=?=, Mar 1, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    5,543
    Steve C. Orr [MVP, MCSD]
    Mar 2, 2005
  2. darrel
    Replies:
    1
    Views:
    429
    Ken Cox [Microsoft MVP]
    Apr 9, 2005
  3. byrd48

    Photo Rotate Image Cached

    byrd48, Oct 30, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    497
    Eliyahu Goldin
    Oct 31, 2005
  4. RC
    Replies:
    1
    Views:
    945
    Bjoern Hoehrmann
    Aug 3, 2006
  5. IanJSparks
    Replies:
    0
    Views:
    1,230
    IanJSparks
    Jan 10, 2008
Loading...

Share This Page