Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#193 Resolution issue

None
closed
Hervé Drolon
None
5
2013-01-09
2011-12-01
runningwaterpro
No

The picture's resolution is 254 dpi,but I get 72 dpi(2835 dpm) by my demo using freeimage.
Sample picture:https://skydrive.live.com/redir.aspx?cid=41f92b6c196e3ad9&resid=41F92B6C196E3AD9!467&parid=41F92B6C196E3AD9!466
OS: Windows 2003
FreeImage version: 3.15.1.0
My demo is developed by Delphi 7, the code is:


const
HUNDRED = 100;
TMP = 39.37;
var
WidthPixel: Single;
HeightPixel: Single;
Dpm: Integer;
pbmp: PFIBITMAP;
begin
if dlgOpen.Execute then
begin
FreeImage_Initialise(True);
pbmp := FreeImage_Load(FIF_JPEG, PAnsiChar(dlgOpen.FileName));
Dpm := FreeImage_GetDotsPerMeterX(pbmp);
if Dpm > 0 then
begin
WidthPixel := FreeImage_GetWidth(pbmp);
HeightPixel := FreeImage_GetHeight(pbmp);
FreeImage_Unload(pbmp);

  lblWidth.Caption := Format(\'%.0f px, %.2f cm\', [WidthPixel, WidthPixel / Dpm * HUNDRED]);
  lblHeight.Caption := Format(\'%.0f px, %.2f cm\', [HeightPixel, HeightPixel / Dpm * HUNDRED]);

  lblDpm.Caption := FloatToStr(Dpm);
  lblDpi.Caption := FloatToStr(Round(Dpm / TMP));
end

end;
end;


Discussion

  • Hervé Drolon
    Hervé Drolon
    2011-12-22

    Many (if not most of) JPEG images do not store the resolution info in the header but store it instead in the Exif segment.
    For JPEG images, you can use the Exif metadata (XResolution, YResolution, ResolutionUnit) to retrieve resolution info.
    See also https://sourceforge.net/projects/freeimage/forums/forum/36111/topic/3962347

    Hervé

     
  • Hervé Drolon
    Hervé Drolon
    2013-01-09

    • status: pending --> closed
    • milestone: -->