ImageEn, unit iexHelperFunctions

GetImageDetails


Declaration

function GetImageDetails(const Filename: string;
                         out Width: Integer;
                         out Height: Integer;
                         out BitsPerPixel: Integer;
                         AutoOrient: Boolean = False
                         ): Boolean; overload;
function GetImageDetails(const Filename: string; AutoOrient: Boolean = False): TPoint; overload;



Description

Return the size and color depth of an image. Result is false if a load error occurs.
The second overload only returns only the width and height (which will be -1,-1 if a load error is encountered).
If AutoOrient is enabled, Width and Height are swapped if digital camera orientation flag is set to _exoNeeds90RotateCW or _exoNeeds270RotateCW.

Note:
Color depth is TImageEnIO.Params.BitsPerSample * TImageEnIO.Params.SamplesPerPixel
You must add the iexHelperFunctions unit to your uses clause
Delphi/C++ 2005 or newer is required

See also: BitsPerPixelToStr


Example

if GetImageDetails('D:\MyImage.jpeg', iWidth, iHeight, iBitsPerPixel) then
begin
  lblWidth.Caption := IntToStr(iWidth);
  lblHeight.Caption := IntToStr(iHeight);
  lblColorDepth.Caption := BitsPerPixelToStr(iBitsPerPixel);
end;