Read image files in C# and VB.NET

GemBox.Imaging allows you to quickly read image files from your C# or VB.NET applications.

Loading an image and getting its information, such as the size and resolution, for example is really straightforward. You can quickly retrieve the image information using a simple API and just a few lines of code.

The following example shows how you can load a PNG image and get its information.

Reading image information in C# and VB.NET
Screenshot of the process of reading information from an input image
Upload your file (Drag file here)
using System;
using GemBox.Imaging;

class Program
{
    static void Main()
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        var imagePath = "%InputFileName%";
        using (var image = Image.Load(imagePath))
        {
            // Display image information
            Console.WriteLine($"Image path: {imagePath}");
            Console.WriteLine($"Image size: {image.Width}x{image.Height}");
            Console.WriteLine($"Image resolution: {image.DpiX}x{image.DpiY}");
        }
    }
}
Imports System
Imports GemBox.Imaging

Module Program

	Sub Main()

		' If using Professional version, put your serial key below.
		ComponentInfo.SetLicense("FREE-LIMITED-KEY")

		Dim imagePath = "%InputFileName%"
		Using image As Image = image.Load(imagePath)
			' Display image information
			Console.WriteLine($"Image path: {imagePath}")
			Console.WriteLine($"Image size: {image.Width}x{image.Height}")
			Console.WriteLine($"Image resolution: {image.DpiX}x{image.DpiY}")
		End Using
	End Sub
End Module

See also


Next steps

GemBox.Imaging is a .NET component that provides an easy way to load, edit, save images. GemBox.Imaging also supports file format conversions and image transformations (resize, crop, rotate and flip).

Download Buy