Link to home
Start Free TrialLog in
Avatar of anorganix
anorganix

asked on

Resize JPG Image

Hi all!
I need to resize a serie of large JPG images (4000x2000) and I need a *fast* algo that will do the job...

Currently I am using a procedure based on "StrechDraw", but it's not fast enough:

//////////////////////// code /////////////////////////

procedure ResizeJPG(InFile, OutFile: string; Percent, Quality: integer);
var
  oJPG: TJPEGImage;
  oBmp: TBitmap;
begin
  try
    oJPG:=TJPEGImage.Create;
    oJPG.LoadFromFile(InFile);
  except
    MessageBox(0,PChar('Cannot open '+ExtractFileName(InFile)+'!'),
               'Error',MB_OK+MB_ICONERROR);
    Exit;
  end;

  oBmp:=TBitmap.Create;
  oBmp.Width:=Round(oJPG.Width*Percent/100);
  oBmp.Height:=Round(oJPG.Height*Percent/100);
  oBmp.Canvas.StretchDraw(Rect(0,0,oBmp.Width-1,oBmp.Height-1),oJPG);

  oJPG.Assign(oBmp);
  oJPG.CompressionQuality:=Quality;
  oJPG.Compress;
  oJPG.SaveToFile(OutFile);

  oBmp.Free;
  oJPG.Free;
end;

///////////////////////// end code /////////////////////////

I will raise the points if I get a good solution!
Thanks in advance!

  :: Cosmin
SOLUTION
Avatar of JeePeeTee
JeePeeTee

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of anorganix
anorganix

ASKER

Graphics32 is preety good at rotating images... but it's too complicated for my purpose...
Any other concise examples?

Thanks,
  Cosmin.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial