var
opendlg:topendialog;
 Jpeg:TjpegImage;
begin
opendlg:=topendialog.create(application);
try
opendlg.filename:=editimagepath.text;
opendlg.Filter:='image(*.jpg)|*.jpg|*.jpg';
opendlg.Options:=opendlg.Options+[ofpathmustexist];
if opendlg.Execute then
begin
editimagepath.text:=opendlg.filename;if not(editimagepath.text='') then
begin
if fileexists(editimagepath.text) then
       begin
       image1.picture.loadfromfile(editimagepath.text) ;
    jpeg:=TjpegImage.Create()   ;
      //image1.picture.LoadFromFile(editimagepath.text);
    jpeg.LoadFromFile(editimagepath.text);
    //jpeg.Assign(image1.Picture.Graphic);
   //application.messagebox(inttostr(jpeg.width),'错误',mb_ok)
jpeg.CompressionQuality:=30;   //压缩率1~100
jpeg.Compress;                               //执行压缩
jpeg.SaveToFile('c:\a.jpg');
image2.Picture.loadfromfile('c:\a.jpg');
jpeg.Free;
   opendlg.Free;
 //保存新图像
editimagepath.text:=''end
   else
application.messagebox('指定图片文件不存在','错误',mb_ok);
 end  elseapplication.messagebox('没有指定jpg图片文件','错误',mb_ok) ;
end  else
begin
application.messagebox('没有指定jpg图片文件','错误',mb_ok) ;
 end ;        finally
end ; end;