Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# LINQ ASP.NET4.0
Hi Guys,
am a student and am developing a project for my first semester i need a help please if any one here to help me then please let me how how can i do this
i want to do resize image size with using c# code in asp.net i make a code that is this

string Headerpath = "~/hf_images/" + FileUploadHeader.FileName;
FileUploadHeader.SaveAs(Server.MapPath(Headerpath));
 
string Footerpath = "~/hf_images/" + FileUploadFooter.FileName;
FileUploadFooter.SaveAs(Server.MapPath(Footerpath));
 
Event.AddEvent(Convert.ToInt32( Headerpath, Footerpath);

what i want to do with my this code there is a two FileUploader (Header and Footer) i want to resize this both images when i click on save button and also want to save Header and Footer new size image path in database and new image in gf_image folder please edit my this code and know me how can i do this and resize hight:20px; and widht:40px; please update my this code and and provide me proper code for that.
Thank You
Posted 12-Jun-12 23:05pm
Edited 12-Jun-12 23:15pm
v4
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

We don't give/edit code here.

There are enough articles/examples on internet of this topic. Look at the links below, they can give you a head start:

Image in C#: Save, Resize, and Convert to Binary[^]

http://www.switchonthecode.com/tutorials/csharp-tutorial-image-editing-saving-cropping-and-resizing[^]
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

public static System.Drawing.Image ScaleImage(System.Drawing.Image image, int maxHeight)
    {
        var ratio = (double)maxHeight / image.Height;
 
        var newWidth = (int)(image.Width * ratio);
        var newHeight = (int)(image.Height * ratio);
 
        var newImage = new Bitmap(newWidth, newHeight);
        using (var g = Graphics.FromImage(newImage))
        {
            g.DrawImage(image, 0, 0, newWidth, newHeight);
        }
        return newImage;
    }

For detail
Click here
  Permalink  
Comments
sandeepwect at 7-Jun-13 10:41am
   
i have uploaded picture in a folder in asp.net project. I want to show the pics on different pages in different size without loosing the quality of the picture. Please solve my query asap.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 6,474
1 OriginalGriff 6,258
2 Peter Leow 2,534
3 Abhinav S 2,274
4 Maciej Los 2,268


Advertise | Privacy | Mobile
Web04 | 2.8.150414.1 | Last Updated 17 Aug 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100