Last post Nov 04, 2008 08:17 AM by s_kushal
Nov 04, 2008 05:44 AM|soona|LINK
How to find image size for width and height in asp.net with c# code?
1. I need to find the image sizes in asp.net with c# source.
2. in my code behind: I need to fix the image size.
3. I need to check uploaded image size and fixed size.
4. If it will be match both the fixed size and uploaded image sizes. The uploaded image must store in database.
Pls give some idea and sample source for how to set width and height value.(fixed value for image)
Nov 04, 2008 08:17 AM|s_kushal|LINK
I cant get the logic of what you want to accomplish but i suppose the following code will be usefull to you.
private static Image resizeImage(Image img, Size size)
int sourceWidth = img.Width;
int sourceHeight = img.Height;
float nPercent =
float nPercentW =
float nPercentH =
if (nPercentH <nPercentW)
nPercent = nPercentH;
nPercent = nPercentW;
int destWidth =
(int)(sourceWidth * nPercent);
int destHeight =
(int)(sourceHeight * nPercent);
Bitmap b = new Bitmap(destWidth, destHeight);
Graphics g = Graphics.FromImage((Image)b);
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
0, 0, destWidth, destHeight);
For full article refer here