.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Resize image

Posted By:      Posted Date: September 10, 2010    Points: 0   Category :ASP.Net
Hello, am writing code for upload image file and save it into disc ,,, during this and before save it to disc I want to resize the image into specified width and Heigh  am trying to use this code if (this.IsValid && this.FileUpload1.HasFile) { //Create an ImageElement to wrap up the uploaded image Neodynamic.WebControls.ImageDraw.ImageElement uploadedImage; uploadedImage = Neodynamic.WebControls.ImageDraw.ImageElement.FromBinary(this.FileUpload1.FileBytes); //Create Resize imaging action to apply on the uploaded image //NOTE: You may apply any of the ImageDraw built-in imaging actions Neodynamic.WebControls.ImageDraw.Resize actResize = new Neodynamic.WebControls.ImageDraw.Resize(); actResize.Width = 150; actResize.LockAspectRatio = Neodynamic.WebControls.ImageDraw.LockAspectRatio.WidthBased; uploadedImage.Actions.Add(actResize); //Composite the output image by using ImageDraw class Neodynamic.WebControls.ImageDraw.ImageDraw imgDraw = new Neodynamic.WebControls.ImageDraw.ImageDraw(); //Add uploaded image imgDraw.Elements.Add(uploadedImage); //Now, save the output image on disk string fileName = @"../images/" + System.IO

View Complete Post

More Related Resource Links

Easy image processing(grayscale, sepia, negative, resize, brightness, contrast and opacity)

Howdie y'all,

I see a lot of questions in this forum about resizing images. Recently I created a code sample(with downloadable webapp), right here.

The class (downloaded or created) allows for very fast and easy processing of your images. And a lot of problems over here can be solved by simply using that class. I thought it might help to mention the code sample in this forum as well.



image resize according to user options

i want to provide user to select images to upload, maximum images is 4.the overall size is 1024px width and 500px height.within this 4 or 3 or 2 images will have to fit.if the user upload 4 images it has to calculate the overall width and height and resize the 4 images as equal width and height for each.if the user upload 2 images it has to calculate the overall width & height and fits.i want to do through code. iam using c# asp.netif any samples plz provide me.

resize image

Image img = Image.FromFile(this.tbPic1.Text.ToString()); Clipboard.SetImage(img); richtextbox1.SelectionStart = 0; rtbrichtextbox1Paste(); Clipboard.Clear(); i can insert picture to richtextbox,but how can i set the width and heigh of the picture before paste into richtextbox. one more question i would like to ask about image in MS Access Database how can i store the image into database using ODBC

Auto resize image width only


I have a question regarding the resizing of images.

My problem is that I would like to resize files that are being uploaded automatically. But I only want to resize the width.

Regarding the height of the file, this should auto adjust it self. Forexample; If I'm uploading a file that is 1000 px in width and 2000px in height and then resize it to 500px in width, then I want the height to be auto resized to 1000px. In other words the height and width has to be proportional. 

Could someone help me out on this. 

Thanks for reading. 

Resize image in gridview


I have a database which stores the path of an image. When the gridview displays, it uses a template field to show the image instead of the path. 

<asp:TemplateField HeaderText="Image">
                    <asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("Image") %>' />


The images in this database may be different to eachother, but I want to resize each picture by a scale factor. Ie. Divide the height by 10, and then the width by 10, then set the height and width to these values. How can I do this for each image in the datagrid?

dynamic Image resize


Hi guys,


I'm trying to dynamically load an image from my code behind file,  however I want to be able to resize the image thus reducing the file size sent to the client.  I've come across a few samples but without much luck.  So far I have the following:

        Dim MyImage As Image
        MyImage = Image.FromFile("d:\flowers.jpg")
        MyImage = MyImage.GetThumbnailImage(100, 100, Nothing, New IntPtr)


Unfortunately I now need to load this image into control panel.but nowhere can I find how to do this.

asp.net vb

DetailsView Image Resize on Upload


I am using a details view to add a name and image path to a database. I have a template with a fileupload control and a dropdown list (landscape and portrait), that is used to get the file name. My question is: How can I resize the image based upon whether the image is landscape or portrait? This is my code so far:

<%@ Page Title="" Language="VB" MasterPageFile="~/Admin.master" AutoEventWireup="false" CodeFile="UploadGallery.aspx.vb" Inherits="Admin_UploadGallery" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
<h1>NTTC Administration: Upload Pictures to Gallery</h1>
    <asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="318px" 
        AutoGenerateRows="False" DataKeyNames="ID" DataSourceID="SqlDataSource1" 
        DefaultMode="Insert" GridLines="None">
            <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" 
                ReadOnly="True" Sor

Resize image and get new byte size without saving it


Hi Guys,

I'm making an application that needs to be able to take a user specified image file and upload it into a database that only accepts images of 10 KB or less. So I want to let the user select an image and then have the option of resizing it and if possible also decreasing the quality - I'm sure I can figure out how to do both of these things on my own but the thing I'm not sure about is how I can tell what size the resulting image will be without actually writing it to disk. I thought the SourceStream property of the BitmapSource class would be useful but when I try to access it I just get told that the stream has been closed. Any ideas?




My website: www.cjwdev.co.uk My blog: cjwdev.wordpress.com

how to resize Image on imagemap


Hi All,

             This is praveen,i have faced one problem please help me any one, it is very urgent, The Position of the Number seems to be absolute on the page,it menas i have taken one image, on that image i have placed one more image with absolute position,in the browser leve 100% ok all images dispaly very good,but when we resize the browser not go with image on image, is there solution to solve this one....................this small images dispaly dynamically generated for Hotspots on image map............................

Thanks In advance:


mali id:nanna.praveenm.hyd@gmail.com

Resize and Crop an image using the graphics.drawimage method


Hello all,

I have been pulling out my hair trying to get this figured out and I need to tap the wisdom of the dotNet elite.

I am running dotNet 3.5 (VB.NET) , IIS7, Windows 7.

Basically, I have constructed a UI using a combination of two JQuery tools. JCrop and Resizable. Both are working on the client side and I need to save the optionally resized and optionally cropped photo after the user has completed their image manipulation.

At the moment, I have a class file that resizes images on the fly and crops them. But they scripts to handle the resized image and the cropped image are separate.

Here is the specifics:

            Dim image As New Bitmap(ThumbWidth, ThumbHeight)
            Dim g As Graphics = Graphics.FromImage(image)

            ' Load the file data.
            Dim thumbnail As System.Drawing.Image
            If ImageProcessType = ProcessType.Filename Then

how to auto resize image then upload ?


how to auto resize image then upload??

any1 can help me?


below is my code:

 If FileUpload1.HasFile Then
                filename1 = FileUpload1.FileName
                savePath1 += filename1

                sSQL1 = "SELECT * from news order by PicID desc"
                conn1 = New SqlConnection(ConnStr)
                cmd1 = New SqlCommand(sSQL1, conn1)
                rd1 = cmd1.ExecuteReader()
                Dim n As Integer
                n = rd1.Item("PicID") + 1
                sSQL = "select * from news"
                conn = New SqlConnection(ConnStr)
                cmd = New SqlCommand(sSQL, conn)
                da = New SqlDataAdapter(cmd)
                cb = New SqlCommandBuilder(da)
                ds = New DataSet
                da.Fill(ds, "news")

                nrow = ds.Tables("news").NewRow()
                nrow("PicID") = n
                nrow("ImagePath") = "~/new/news_images/" + filename1
                nrow("Tittle") = tittle
                da.Update(ds, "news")

                FileUpload1.SaveAs(Server.MapPath("/new/news_images/" & filename1))
                lblmsg1.Text = "Image Upload Successful!"

Built-in Functions - Text and Image Functions in SQL Server

Text and image functions operate on TEXT, NTEXT and IMAGE data types. These data types are deprecated with SQL Server 2005 and should be replaced by VARCHAR(MAX), NVARCHAR(MAX) and VARBINARY(MAX) when possible. Alternatively you can also consider storing large string values using XML data type. Text and image functions are nondeterministic.

Future versions of SQL Server will not support TEXT, NTEXT and IMAGE data types. Columns with TEXT / NTEXT data type do not support commonly used string functions such as LEN, LEFT, RIGHT, etc. Furthermore, due to the large size of TEXT data you''re likely to see performance issues if you store such data in the database. However, at times you can''t help but use the TEXT / NTEXT / IMAGE data types (for example when supporting 3rd party databases when you cannot change the schema) - this is when text and image functions come in handy.

Program for Format Conversion of An Image

.NET provides extensive support for image conversion. Any image can be processed from one format to another. Most common formats to which .NET have support for are .BMP, .EMF, .GIF, .ICO, .JPG, .PNG, .TIF and .WMF.

Configuring Profile Image Export in SharePoint 2010

It's no secret that I am thrilled with the new social features of SharePoint 2010. I am most excited about the new Profile Picture handling. I strongly believe that the more we can show the faces of our colleagues to one another the more connected we will feel. Clearly Microsoft feels that way as witnessed by the many features that make use of the Profile Image like the Activity Feed and Colleagues list

Built-in Functions - Text and Image Functions

Text and image functions operate on TEXT, NTEXT and IMAGE data types. These data types are deprecated with SQL Server 2005 and should be replaced by VARCHAR(MAX), NVARCHAR(MAX) and VARBINARY(MAX) when possible. Alternatively you can also consider storing large string values using XML data type. Text and image functions are nondeterministic.

ASP.Net Upload Image to MS Access Database

As you learnt from the previous articles to upload image to the SQL Database in ASP.Net 2.0 and stream that image into the memory to retrieve it from the database and display it on the web page. In this article you will learn how to upload images to the MS Access database in ASP.Net 2.0

First of all create an Access Database and place it in the App_Data folder of ASP.Net web site project. Then create a table "tblImg" with the following fields:

Get pixel format, raw format, property id list and property items image in VB.net - C#.net.

n this simple article you will learn that how we can get pixel format, raw format, property id list and property items image in VB and C#.net.

Get Pixel Format:

Image consists of pixels to get the format of the pixel we have a property named pixel format. This property returns an enumeration of pixel format. This enumeration tells the pixel format.

To demonstrate make a window application. Drag one button and a picture box on form.

Now write the following code on Button click event:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend