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.

using System;
using GemBox.Imaging;
class Program
{
static void Main()
{
// If using the 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 the 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
Published: September 14, 2022 | Modified: December 19, 2022 | Author: Ercan Görgülü