'Metafile is not valid'

Hi,

I have writen the procedure below to shrink an image (jpg) so it will fit
into a list on a report.  However when I run the report I get the following
message on some of the images:-

Project NewArtist.exe raised exception class EInvalidGraphic with message
'Metafile is not valid' Process stopped...

What realy puzzles me is that the image(s) show OK in the main program and a
thumbnail view using similar code.

I am using D5 Pro with service pack added.

Can anyone help/advise.

Regards

Dave
_______________________________________________
procedure TSReport.SizeImages;
const
  maxW: double = 100; maxH: double= 70;
var
  fw,fh,f1,f2,fd : double;
Begin
  s:=D.Q_PI.Fieldbyname('PictureLoc').asString;
  If s='' then s:='y:\Pictures\nopic.jpg';
  S_picture.Picture.LoadFromFile(s);
  fw:= Round(S_picture.Picture.Width);
  fh:= Round(S_picture.Picture.Height);
  f1:= fw/maxW;
  f2:= fh/maxH;
  if f1 > f2 then fd:=f1 else fd:=f2;
  if fd=0 then fd:=10;
  S_picture.Width := Round(fw/fd);
  S_picture.Height:= Round(fh/fd);
  S_picture.Stretch:= true;
end;

procedure TSReport.DetailBand1BeforePrint(Sender: TQRCustomBand;
  var PrintBand: Boolean);
begin
  SizeImages;
end;
_______________________________________________