0

Hi
How can i resize an image before uploading and saving to database to the size im showing in my application.How will i accomplish this.

2
Contributors
4
Replies
7
Views
8 Years
Discussion Span
Last Post by Dhaneshnm
0

My aspx page

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Image Resizing Demo</title>
    
    
</head>
<body>
    <form id="form1" runat="server" action="Default.aspx"  method="post">
    <div>
        <asp:FileUpload ID="Selectedfile" runat="server" />
        &nbsp;
        <asp:Button ID="Button1"   runat="server" OnClick="Button1_Click1"/>
        </div>
        
    </form>
    
</body>
</html>

Now the important parts of code behind,

public bool ThumbnailCallback()
    {
        return false;
    }
    protected void Button1_Click1(object sender, EventArgs e)
    {
        System.Drawing.Image.GetThumbnailImageAbort myCallBack
   = new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback);

        System.Drawing.Image im = System.Drawing.Image.FromStream(Selectedfile.FileContent);
        System.Drawing.Image smallim = im.GetThumbnailImage(20, 20, myCallBack, IntPtr.Zero);/*put what ever size you want instead of first 
two parameters,they stand for width and height*/
        

    }

Code is in c#.But functionality wont differ in vb.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.