Read image files

The following example shows how to use GemBox.Imaging to load an image file and read its size and resolution information.

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

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 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 = "%InputFileName%"
        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

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