Tutorial: Extract Image Info with the CodecsImageInfo Class

Like people, images are all different. Even though some images may look the same, there can be hidden information within the properties that make them unique. Perhaps you find yourself currently in a workspace that is going paperless and need a way to convert image files to the same format, size, or bits-per-pixel. You’ll first need to be able to quickly check the various image properties to see which ones already match your needs and which ones don’t.

LEADTOOLS offers developers an easy way to extract this image information with the CodecsImageInfo Class. This class provides methods to get information about images. There are hundreds of different image properties that can obtained with this class.

The essential code can be found below, but be sure to check out the full step-by-step tutorial to Extract Image Info. This will show you how to create a Windows Console application in C# that utilizes the CodecsImageInfo Class to get information from the various image formats supported by LEADTOOLS.

using (RasterCodecs codecs = new RasterCodecs()) 
{
	CodecsImageInfo info = codecs.GetInformation(fileName, true);
	string inputFileName = Path.GetFileNameWithoutExtension(fileName);
	string codecsInfoString = ($"Image Format: {info.Format}\n" +
		$"Information for: {inputFileName}\n" +
		$"BitsPerPixel: {info.BitsPerPixel}\n" +
		$"BytesPerLine: {info.BytesPerLine}\n" +
		$"ColorSpace: {info.ColorSpace}\n" +
		$"Byte Order: {info.Order}\n" +
		$"Image Height: {info.Height}\n" +
		$"Image Width: {info.Width}\n" +
		$"Image X Resolution: {info.XResolution}\n" +
		$"Image Y Resolution: {info.YResolution}\n" +
		$"Compression: {info.Compression}\n" +
		$"Page Number: {info.PageNumber}\n" +
		$"Total Pages: {info.TotalPages}");
		Console.WriteLine(codecsInfoString);
		Console.ReadLine();
}

Try it out!

To test this for yourself, make sure to get the latest LEADTOOLS SDK code for free straight from our site if you have not already. This trial is good for 60 days and comes with unlimited chat and email support.

Support

Need help getting this sample up and going? Contact our support team for free technical support! For pricing or licensing questions, you can contact our sales team (sales@leadtools.com) or call us at 704-332-5532.


Stay tuned because, as promised in our previous post, we’ll be featuring more tutorials that programmers can use to develop applications that will directly impact data capture, recognition, exchange, and other pressing business needs.

About 

Developer Advocate

    Find more about me on:
  • linkedin
  • twitter
  • youtube
This entry was posted in General Imaging. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *