sexta-feira, 12 de julho de 2019

Reduzir tamanho imagem

uses Vcl.Imaging.jpeg;


function CAPAS_REDUZ(ORIG,DEST:string; const fWidth, fHeight: integer):Boolean;
var pTemp: TBitmap;
begin
try
try
pTemp := nil;
ptemp := TBitmap.Create;
pTemp.LoadFromFile(ORIG);
if (pTemp.Width > fWidth) or (pTemp.Height > fHeight) then
begin
pTemp := pTemp.CreateThumbnail(fWidth,fHeight);
pTemp.SaveToFile(DEST);
end
else
CopyFile(PChar(ORIG), PChar(DEST), true);
result := true;
finally
FreeAndNil(pTemp);
end;
except
FreeAndNil(pTemp);
result := false;
end;
end;

Nenhum comentário: