I have never been able to get Delphi to compress a jpeg image. I set CompressionQuality to any value and then call Compress but the file is always saved with a length of zero bytes. Can someone tell me what I'm doing wrong? (It fails, for me, with Delphi 5 and Delphi 7).
Andrew
Code:
uses jpeg;
procedure TForm1.GoClick(Sender: TObject);
const
path = 'c:\';
var
jpeg: TJpegImage;
begin
jpeg := TJpegImage.Create;
try
jpeg.LoadFromFile( path + 'Old.jpg');
jpeg.CompressionQuality := 50;
jpeg.Compress;
jpeg.SaveToFile ( path + 'New.jpg' );
finally
jpeg.Free;
end;
end;
Andrew