473,406 Members | 2,451 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How do I get the dimensions of a graphic file?

I have two jpegs -- one portrait, one landscape. I need the ability to tell
the length and height of the graphic for further processing. How can I do
this using CSharp?

thank you
Sep 7 '07 #1
3 1196
System.Drawing.Image img = System.Drawing.Image.FromFile(filePath);
int w = img.Height;
int h = img.Width;

http://msdn2.microsoft.com/en-us/lib...ge(VS.71).aspx

--
HTH,

Kevin Spencer
Microsoft MVP

DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

"CSharpie" <CS******@discussions.microsoft.comwrote in message
news:B6**********************************@microsof t.com...
>I have two jpegs -- one portrait, one landscape. I need the ability to
tell
the length and height of the graphic for further processing. How can I do
this using CSharp?

thank you

Sep 7 '07 #2
"CSharpie" <CS******@discussions.microsoft.comschrieb im Newsbeitrag
news:B6**********************************@microsof t.com...
>I have two jpegs -- one portrait, one landscape. I need the ability to
tell
the length and height of the graphic for further processing. How can I do
this using CSharp?

thank you
You can use the FromFile (or FromStream) Method of the System.Drawing.Image
Class to create an Image instance and then look at the Width and Height
properties.

Christof
Sep 7 '07 #3
Kevin, your answer was right on. I wish I knew the .net libraries as well as
you.

thanks

"Kevin Spencer" wrote:
System.Drawing.Image img = System.Drawing.Image.FromFile(filePath);
int w = img.Height;
int h = img.Width;

http://msdn2.microsoft.com/en-us/lib...ge(VS.71).aspx

--
HTH,

Kevin Spencer
Microsoft MVP

DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

"CSharpie" <CS******@discussions.microsoft.comwrote in message
news:B6**********************************@microsof t.com...
I have two jpegs -- one portrait, one landscape. I need the ability to
tell
the length and height of the graphic for further processing. How can I do
this using CSharp?

thank you


Sep 7 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Sandman | last post by:
Hello, An html authoring question: What is the correct syntax to write into a root directory "index file" (mainpage file) so it will point to a graphic file located in another directory?...
6
by: MurrayTh | last post by:
Is there any way to determine the dimensions of an image using the image's URL? ie load image based on URL, and then get dimensions? or perhaps better method?
13
by: Stacey Levine | last post by:
Ok.. Maybe I am trying the wrong approach. If given a URL to a graphic, I want to save that graphic to a local file. The approach below gets the response, but I can't quite figure out how to save...
1
by: hamil | last post by:
I am trying to print a graphic file (tif) and also use the PrintPreview control, the PageSetup control, and the Print dialog control. The code attached is a concatination of two examples taken out...
1
by: krimgelas | last post by:
Hello, I have a vcd sized movie file (dimensions 352x288) that I want to embed in my web page. For this I use the <object> element: ===== BEGIN <object width="240" height="196"> <param...
7
by: Neo Geshel | last post by:
Greetings. I have managed to stitch together an awesome method of posting text along with an image to a database, in a way that allows an unlimited number of previews to ensure that text and...
1
by: Mentat | last post by:
In the description below ??? marks specific problem areas. Any help is appreciated. Required ======== A method to detect the width and height values of a <DIV... element. Since there are two...
1
TheMadMidget
by: TheMadMidget | last post by:
If I have an .avi file is it possible for php, anything else too but hopefully php, to read the dimensions of the video file. In case anyone is wondering why, I'm trying to embed them using DivX web...
2
by: Adam Teale | last post by:
hey guys Is there a builtin/standard install method in python for retrieving or finding out an image's dimensions? A quick google found me this:...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.