Read image files in C# and VB.NET

The GemBox.Imaging library supports the PNG, JPEG, GIF, and TIFF image file formats.

The following example shows how to use GemBox.Imaging to load an image file and read its size and resolution information, in C# and VB.NET.

Upload your file (Drag file here)
using GemBox.Imaging;
using System;

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

var imagePath = "deer.jpg";
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 GemBox.Imaging
Imports System

Module Program

Sub Main()

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

Dim imagePath = "deer.jpg"
Using image = GemBox.Imaging.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
Reading image information in C# and VB.NET
Screenshot of the process of reading information from an input image

Next steps

GemBox.Imaging is a .NET library 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).