• Welcome to Vampyre Imaging Library Forum. Please login or sign up.
 

JPG throws exception when it contains no resolution information

Started by Bernd, 15 June 2010, 14:49:22

Previous topic - Next topic

Bernd

Version: current trunk from svn
Compiler: FPC 2.5.1/Lazarus
Operating system: Windows 7 (x64)

JPEG throws exception when loading thru

aJPEG: TImagingGraphic;
...
aJPEG := TImagingGraphic.Create;
aJPEG.LoadFromFile('TMP68830.jpg');
aJPEG.Free;

The exception is thrown in "imaging.pas" (TMetadata.TranslateUnits) in line 3934, because the image does not contain any x or y resolution. In this case the call

    XRes := UnitSize / XRes;
    YRes := UnitSize / YRes;     

causes an "div zero" exception. I recommend to check the content of "Xres" and "Yres" and if zero, set it to a default value (72 or 96dpi).

This is a working solution for the problem:

    if XRes <=0 then Xres := 96;
    if YRes <=0 then Yres := 96;
    XRes := UnitSize / XRes;
    YRes := UnitSize / YRes;

Regards
Bernd


Galfar

Thanks for reporting this, I'll fix it right away. 
New features in the trunk haven't been tested that much yet.

Quick Reply

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Name:
Email:

Shortcuts: ALT+S save/post or ALT+P preview

SMF spam blocked by CleanTalk