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.

You can use image class and GetThumbnailImage() method to resize
the image.

Can u please explain how to use these methods?

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.

On more thing,resizing the height/width will reduce the size in bytes accordingly

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.