0
    var bmpOutput = new Bitmap(@"1_0.jpg");

    foreach (var item in bmpOutput.PropertyItems)
    {
        var id = item.Id; // 20625
        var length = item.Len; // 128
        var type = item.Type; // 3 ( MSDN says that 3 : Specifies that Value is an array of unsigned short (16-bit) integers.
        var byteArray = item.Value; // length 128

        var result = BitConverter.ToUInt16(byteArray, 0); // 1 but must be 96
    }

I try to retrieve image dpi, but I can't convert the byte array to an integer value. I want to get vertical and horizontal resolution from jpg(96x96).

enter image description here

Adam Hodovanets
  • 223
  • 1
  • 2
  • 11

1 Answers1

0

The properties that you need are in the Image class, a Bitmap inherits from it so:

var dpiX = ((Image)bmpOutput).HorizontalResolution;
var dpiY = ((Image)bmpOutput).VerticalResolution;

Can also check: How to Get DPI of Image in C#