Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 07/01/21 in all areas

  1. David Heffernan

    Physically reduce jpeg image size??

    The thing is, both resizing and compression will change the image and only you can judge which you prefer. It depends on what you are trying to do with these images, what sort of images they are. In my view you need to engage with that side of things first, not in a coding setting, to work out precisely what transformation you want. Then implementing it in code should be simple.
  2. ConstantGardener

    Physically reduce jpeg image size??

    function ResponseWithScaledJPG (const AFilename : string; var Response: TIdHTTPResponseInfo) : boolean; var JPEGImg : TJPEGImage; AStream : TStream; begin result:=false; if FileExists (AFilename) then begin AStream := TMemoryStream.Create; JPEGImg := TJpegImage.Create; try JPEGImg.LoadFromFile(AFilename); if JPEGImg.Width<500 then JPEGImg.Scale:=jsFullSize else if JPEGImg.Width<1000 then JPEGImg.Scale:=jsHalf else if JPEGImg.Width<2000 then JPEGImg.Scale:=jsQuarter else JPEGImg.Scale:=jsEighth; JPEGImg.SaveToStream(AStream); result:=true; finally JPEGImg.Free; Response.ContentType := mime.ImageJPeg; Response.ContentStream := AStream; end; end; end; ....use this as base for your own solution. This function is from a little INDY webserver for responding with scaled pic's to jpeg-requests for limiting the traffic payload.
×