Topic: Resize jpeg image for DBImage

Resize jpeg image for DBImage, if picture bigger that width of DBImage component
Works beginning from version 4.5


added function:

function JpegResize(InJpgFile, OutJpgFile: string; NewWidth: integer = -1; NewHeight: integer = -1; Quality: integer = 80): boolean;

Example:

procedure frmEmployee_ButtonSave_OnClick (Sender: TObject; var Cancel: boolean);
var
    Filename, Path: string;
begin
    if frmEmployee.DBImage1.dbImageIsChanged then
    begin
        if frmEmployee.DBImage1.Picture.Width > frmEmployee.DBImage1.Width then
        begin
            Filename := ExtractFileName(frmEmployee.DBImage1.dbFileName);
            Path := ExtractFilePath(frmEmployee.DBImage1.dbFileName);
            if JpegResize(frmEmployee.DBImage1.dbFileName, Path+'resized_'+Filename, frmEmployee.DBImage1.Width) then
            begin
                frmEmployee.DBImage1.Picture.LoadFromFile(Path+'resized_'+Filename);
                DeleteFile(Path+'resized_'+Filename);
            end;
        end;

    end;
end;


Project:

Post's attachments

Attachment icon Resize Jpeg for DBImage.zip 19.88 kb, 62 downloads since 2018-06-01 

Dmitry.