If you want to know the format of an image, you can load the file with the Image class, and check its RawFormat property:
using(Image img = Image.FromFile(@"C:\path\to\img.jpg"))
{
if (img.RawFormat.Equals(System.Drawing.Imaging.ImageFormat.Jpeg))
{
// ...
}
}
Related Contents:
- Setting WPF image source in code
- Getting image dimensions without reading the entire file
- Merging two images in C#/.NET
- Drag and drop files into WPF
- Image vs Bitmap class
- Download image from the site in .NET/C#
- How do I programmatically save an image from a URL?
- Are there any OK image recognition libraries for .NET?
- Converting Bitmap PixelFormats in C#
- Validate image from file in C#
- Image.Save() throws exception “Value cannot be null./r/nParameter name: encoder”
- how can I convert System.Drawing.Icon to System.Drawing.Image?
- How do I display a decimal value to 2 decimal places?
- In C#, should I use string.Empty or String.Empty or “” to intitialize a string?
- Using LINQ to remove elements from a List
- When should I use GC.SuppressFinalize()?
- How to find the Number of CPU Cores via .NET/C#?
- What is the default value for enum variable?
- What is the difference between int, Int16, Int32 and Int64?
- What’s the difference between an object initializer and a constructor?
- xUnit.net: Global setup + teardown?
- How to remove the focus from a TextBox in WinForms?
- When is it better to use String.Format vs string concatenation?
- Troubleshooting BadImageFormatException
- Create a dictionary on a list with grouping
- STAThread and multithreading
- How to compare Unicode characters that “look alike”?
- Don’t stop debugger at THAT exception when it’s thrown and caught
- How to save MailMessage object to disk as *.eml or *.msg file
- Why use ImmutableList over ReadOnlyCollection?
- System.Security.SecurityException: The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security
- Why are operators so much slower than method calls? (structs are slower only on older JITs)
- Adding scripting functionality to .NET applications
- Command for WPF TextBox that fires up when we hit Enter Key
- Can you catch a native exception in C# code?
- How to use StringBuilder wisely?
- How to make Databinding type safe and support refactoring?
- How to get csc.exe path?
- Get file’s size from bytes array (without saving to disc)
- MongoDB GridFs with C#, how to store files such as images?
- Where can I learn about MEF? [closed]
- Catch two exceptions in the same catch block?
- C++/CLI: why should I use it?
- How to determine whether T is a value type or reference class in generic?
- Should I always disconnect event handlers in the Dispose method?
- Is it possible to copy code from Visual Studio and paste formatted code to OneNote?
- Server Client send/receive simple text
- Refresh Page C# ASP.NET
- How to start WinForm app minimized to tray?
- What is the use of ConvertBack method in IValueConverter interface?