Get Image Type Extension : File Name « File Stream « C# / C Sharp

Get Image Type Extension


using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.Windows.Forms;
using System.Text.RegularExpressions;
using System.IO;
using System.Drawing.Imaging;
using System.Reflection;

namespace SuchSofts.OpenImage.Lib.Operation
    internal class CommonOperations

        public static string GetImageExtension(System.Drawing.Image image)
            Type Type = typeof(ImageFormat);
            System.Reflection.PropertyInfo[] imageFormatList = Type.GetProperties(BindingFlags.Static | BindingFlags.Public);
            for (int i = 0; i != imageFormatList.Length; i++)
                ImageFormat formatClass = (ImageFormat)imageFormatList[i].GetValue(null, null);
                if (formatClass.Guid.Equals(image.RawFormat.Guid))
                    return imageFormatList[i].Name.ToLower();
            return "";


Related examples in the same category

1.Query file name with Linq
2.Clean File Name
3.Retrieves the date from the beginning of the WinSat filename and creates a datetime object from it
4.Get File Name
5.Convert To Legal File Name
6.Get File Name From Path
7.Extracts a path part of a full path filename, searching for the last directory separator or column.
8.Creates a relative path from absolute pathfilename and a reference path.
9.Get file extension
10.Restrict a list of files to valid extensions only
11.Get Content Type by Extension
12.Get Full Path Without Extension
13.Full Name Without Extension
14.Name Without Extension
15.ImageFormat to Extension
16.Gets the extension without the dot