Change dimension image uploaded

3 posts, 0 answers
  1. Fabio Cirillo
    Fabio Cirillo avatar
    181 posts
    Member since:
    Jan 2010

    Posted 19 Feb 2013 Link to this post

    is possible before or after uploading an image, change its dimensions?
    Why I load the images into a div via css and I set the background-size, it works on all browsers except on IE8. Here the image does not change size. So I was thinking that it was better to directly change the size of the uploaded file. How can I do?
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 20 Feb 2013 Link to this post

    Hi Fabio

    I suppose that you want to resize images after uploading
    Check the following documentation to resize images.
    How to Resize Images
    Hope this helps

    Thanks
    Princy.

  3. Fabio Cirillo
    Fabio Cirillo avatar
    181 posts
    Member since:
    Jan 2010

    Posted 20 Feb 2013 Link to this post

    ok i would use this code:
    Private Sub CreateBigThumbNail(ByVal newWidth As Integer, ByVal file As UploadedFile)
    Dim target As String = Server.MapPath("~/UploadedImages")
    If Not Directory.Exists(target) Then
    Directory.CreateDirectory(target)
    End If
    file.SaveAs(Path.Combine(target, file.GetName()))
    Using originalImage As New Bitmap(file.InputStream)
    Dim width As Integer = newWidth
    Dim height As Integer = (originalImage.Height * newWidth) / originalImage.Width
    Dim thumbnail As New Bitmap(width, height)
    Using g As Graphics = Graphics.FromImage(DirectCast(thumbnail, System.Drawing.Image))
    g.DrawImage(originalImage, 0, 0, width, height)
    End Using
    Dim thumbnailFileName As String = Path.Combine(target, String.Format("{0}_bthumb{1}", file.GetNameWithoutExtension(), file.GetExtension()))
    thumbnail.Save(thumbnailFileName)
    End Using
    End Sub

    and then what value should I enter in the item ByVal file As UploadedFile
Back to Top