473,406 Members | 2,352 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 to determine the image type loaded with FromFile

Hi All,

I was hoping to be able to determine what format image I
had loaded using code similar to that listed below. And
this does seem to work for all by the Exif format files
which are always detected as Jpeg. Is there a trick to
finding out if the image is a Exif without going though
the PropertyItems.

Thanks Bruce

oImage = Bitmap.FromFile("C:\ABC.JPG");

string sFormat = "Unknown";

if (oImage.RawFormat.Equals(ImageFormat.Bmp))
sFormat = ImageFormat.Bmp.ToString();
else if (oImage.RawFormat.Equals(ImageFormat.Emf))
sFormat = ImageFormat.Emf.ToString();
else if (oImage.RawFormat.Equals(ImageFormat.Exif))
sFormat = ImageFormat.Exif.ToString();
else if (oImage.RawFormat.Equals(ImageFormat.Gif))
sFormat = ImageFormat.Gif.ToString();
else if (oImage.RawFormat.Equals(ImageFormat.Icon))
sFormat = ImageFormat.Icon.ToString();
else if (oImage.RawFormat.Equals(ImageFormat.Jpeg))
sFormat = ImageFormat.Jpeg.ToString();
else if (oImage.RawFormat.Equals(ImageFormat.MemoryBmp))
sFormat = ImageFormat.MemoryBmp.ToString();
else if (oImage.RawFormat.Equals(ImageFormat.Png))
sFormat = ImageFormat.Png.ToString();
else if (oImage.RawFormat.Equals(ImageFormat.Tiff))
sFormat = ImageFormat.Tiff.ToString();
else if (oImage.RawFormat.Equals(ImageFormat.Wmf))
sFormat = ImageFormat.Wmf.ToString();

Console.WriteLine(sFormat);
Nov 15 '05 #1
0 3088

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

Similar topics

16
by: Donjuan | last post by:
Hi all I have trouble with tracking whether my image file is loaded. i use DHTML to change my image. HERE is the code: <img name="someimage" src="1.jpg"...
7
by: Scott Schluer | last post by:
Is there a way to use the Image class to convert a color photo (GIF or JPEG) to a B&W photo? Thanks, Scott
2
by: steve | last post by:
imports system.drawing imports system.drawing.image dim img as image = image.fromfile("a.bmp") picturebox1.image = img i'm using vs 2003 and the error i have is that fromfile is not a member...
6
by: Patrick Dugan | last post by:
Hello, I'm trying to load different images (icons) into a PictureBox1.Image. The first image loads just fine, but the second image always returns the error "Invalid property used." It doesn't...
15
by: David Lozzi | last post by:
Howdy, I have a function that uploads an image and that works great. I love ..Nets built in upload, so much easier than 3rd party uploaders! Now I am making a public function that will take the...
4
by: Bruce | last post by:
I have an asp.net page that is dynamically building a table and populating cells with images (typically jpeg) and with associated metadata. How can the asp.net code efficiently determine the...
4
by: escristian | last post by:
Hello. I'm trying to create an Image so I use something like this: Image newImage = Image.FromFile(filename); Now when it's a bmp file and certain .gif files it gives me an exception that...
5
by: Jerry J | last post by:
I want to use the System.Drawing.Image class. According to the help file, this is an abstract base class. Because it is supposedly abstract, I created another class that inherits from it. However,...
14
by: Steve K. | last post by:
I have a method that I use to get a System.Drawing.Image from a file without keeping a handle on the file open (so I can delete the file). Here is the code: <code> public static Image...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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,...

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.