|
Get Width And Height Of Image In C#
To get width and height of an image we can use System.Drawing.Image class. This code snippet shows how to retrieve width and height of an image.
string filePath = @"c:\deepak\MeeGo.jpg";
Image img = Image.FromFile(filePath);
Console.WriteLine(string.Format("Height: {0}",img.Size.Height));
Console.WriteLine(string.Format("Width: {0}",img.Size.Width));
Leave a Reply
15531 views, 6 so far
today |
Get Updates By Email
Popular Post
Tag Cloud
Code Snippets
- Get Current Windows User In C#
- Get Width And Height Of Image In C#
- Get Windows Registry Size With WMI And C#
- Reverse Array Elements Using C#
- Convert Hexadecimal To Number In C#
- Get Free Disk Space Using T-SQL
- SQL Server 2008 – Get All Indexes In A Database
- Get Name Of Current Executing Assembly In C#
- Get CD Or DVD Drive Information Using WMI And C#
- Get Last Row From Table Using LINQ To SQL


October 31st, 2010 at 12:08 pm
Errors. – pri_height and Height
Error 1 The name ‘Height’ does not exist in the current context C:\299-TwoDShape\Program.cs 12 17 299-
Why pri_height and Height have errors ???
the Complete Refernce C# 4.0
TwoDShape
using System;
class TwoDShape
{
double pri_width;
double pri_height;
public TwoDShape()
{
Width = Height = 0.0;
}
public TwoDShape(double w, double h)
{
Width = w;
Height = h;
}
public TwoDShape(double x)
{
Width = Height = x;
}
public TwoDShape(TwoDShape ob)
{
Width = ob.Width;
Height = ob.pri_height;
}
public double Width
{
get { return pri_width; }
set { pri_width = value < 0 ? -value : value; }
}
public double Heigth
{
get { return pri_heigth; }
set { pri_heigth = value < 0 ? -value : value; }
}
January 21st, 2011 at 11:11 pm
Check this code
if (FileUpload1.HasFile)
{
string path = Server.MapPath(“Twinkle”);
string filename = FileUpload1.FileName;
FileUpload1.SaveAs(path + “/” + filename);
string filePath = path + “/” + filename;
System.Drawing.Image img = Bitmap.FromFile(filePath);
Console.WriteLine(string.Format(“Height: {0}”, img.Size.Height));
Console.WriteLine(string.Format(“Width: {0}”, img.Size.Width));
}
May 16th, 2011 at 5:50 pm
thanks for your take
January 8th, 2012 at 10:52 pm
me using the above mentioned code but getting a error like ‘System.Web.UI.WebControls.Image’ does not contain a definition for ‘FromFile’ plz help what should do for removing this error.is there any library added??
January 9th, 2012 at 10:09 am
Johns,
Use the image class from System.Drawing namespace.