.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

dynamic Image resize

Posted By:      Posted Date: October 08, 2010    Points: 0   Category :ASP.Net

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

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.



Dynamic Image Buttons in GridView not doing partial post back

Hi Gurus - Create a gridview with AllowPaging and AllowSorting = true- On page load, I bind it to datasource (in my case a webservice) - On gridview's rowcreated event, I dynamically add image buttons on the header of the grid for sorting (up/down arrows). On header I have column name and the image. I removed the Column name default sorting link. So user can now only click the image button for sorting.-  Call sorting method This works perfectly fine without AJAX. The paging, sorting works fine. Also when I apply AJAX the paging works fine. But the sorting is doing a full post back instead of partial postback. I have my gridview within UpdatePanel and Triggeres is set on gridview sill it doesn't work.ASPX Code<form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server" /> <div> <asp:Label ID="lblAccount" runat="server" Text="Account #: "></asp:Label> <asp:TextBox ID="txtAccountNumber" runat="server">12203A30</asp:TextBox> <asp:Button ID="cmdGo" runat="server" Text="Go" OnClick="cmdGo_Click" /><br /> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> &l

Resize image

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

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. 

"view state" does't work for Image's ImageURL in dynamic controls


Hi all. in my page_load method I call a mthod that it create some dynamic controls. one of them is an Image control that it's ImageURL property set to an URL that is saved in data base. image shows that URL but when postback ocuurs, previous image controls doesn't their image. but other controls for example TextBoxes keep text values. what should I do for keep image url property for this dynamic Images controls?


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?

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

How do I create a dynamic image in report server


I have two questions about report server.

Question 1: Is it wise to 1300 users to make use of reporter server order forms to print / view? or are better solutions?

Question 2: In a report to a dynamic image. The picture is on the Internet. http://www.domainname.com/images/12500.jpg
How can I display dynamic image in the report?
The filename can be retrieved from the database with the order number.

I was thinking something like: http://www.domainname.com/images/ (Fields! Article.Value)
This work, unfortunately.

Does anyone have an idea?

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!"

Adding Dynamic Rows in ASP.NET GridView Control with TextBoxes and with Delete functionality

In my previous examples, I have demonstrated on how to add dynamic rows in GridView control with TextBoxes and how to save the values into the database. Now, seems that most of the developers are asking if how to add a delete functionality with it. So in this example, I'm going to show on how to delete a certain row in the dynamic GridView with TextBoxes.

Dynamic Data Templates in GridView ASP.NET 3.5

At a high level, Dynamic Data Templates can be seen as a system to very quickly build up a User Interface linked with the relevant data model, immediately enabling you to perform CRUD operations (Create, Read, Update, Delete) on the database using the specified data source. They provide a powerful method for building up these kinds of applications, and I'm going to focus on an overview of what Dynamic Data Templates actually are, and a few ways of customizing them to suit industry needs.

ASP.NET 4.0 Dynamic Data and Many to Many Entity Framework Entities

I did not play much with Dynamic Data controls in VS2008 and just made a cool discovery in VS2010 Beta 2. This may not even be new, but as I'm sitting 30,000+ feet over the Atlantic ocean, I don't have access to VS2008 at the moment to check.
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