using System.Drawing.Imaging; //... string fileName = // path to image file ImageFormat imageFormat = Image.FromFile(fileName).RawFormat; ImageType imageType; if (imageFormat.Equals(ImageFormat.Bmp)) { imageType = ImageType.BMP; } else if (imageFormat.Equals(ImageFormat.Jpeg)) { imageType = ImageType.JPEG; } else if (imageFormat.Equals(ImageFormat.Png)) { imageType = ImageType.PNG; } else if (imageFormat.Equals(ImageFormat.Gif)) { imageType = ImageType.GIF; } else { // handle unknown image format } Console.WriteLine("Image type: " + imageType);In this example, we use the Image.FromFile() method to read in the image file, and then we use the RawFormat property to get the image's format. We then compare the format to the known image formats using the ImageFormat enum, and assign the appropriate ImageType. This code assumes you're using the System.Drawing.Imaging namespace. Package library: The package library for ImageType is likely to be either the .NET Framework or .NET Core, as it is part of the standard C# language's libraries.