Declaration
function LoadFromFile(const FileName: string; bCheckUnknown: Boolean = True): boolean;
Description
Load an image from file (of any format supported by the
TImageEnIO class).
If
bCheckUnknown is true and the file extension is not known or is incorrect (e.g. a GIF file named MyImage.jpg), then loading will be attempted by analyzing the file content (in the same way as
LoadFromFileAuto).
Result will be
False if the file is not a recognized file type. Loading errors due to a file not being available will raise an exception.
Note: For legacy reasons, LoadFromFile() is an alias of Read()
var
bmp: TIEBitmap;
begin
bmp := TIEBitmap.Create();
bmp.LoadFromFile('input.jpg');
bmp.SaveToFile('output.jpg');
bmp.Free();
end;
Which is the same as...
with TIEBitmap.Create('input.jpg') do
begin
Write('output.jpg');
Free;
end;
Also, the same as...
var
bmp: TIEBitmap;
io: TImageEnIO;
begin
bmp := TIEBitmap.Create();
io := TImageEnIO.CreateFromBitmap(bmp);
io.LoadFromFile('input.jpg');
io.SaveToFile('output.jpg');
io.Free();
bmp.Free();
end;
// Convert an SVG file to JPEG at max size of 1000x1000 (will be adjusted to maintain aspect ratio)
var
bmp: TIEBitmap;
begin
bmp := TIEBitmap.Create();
try
bmp.Params.LoadToWidth := 1000;
bmp.Params.LoadToHeight := 1000;
bmp.Params.AutoScaleImport := True;
bmp.LoadFromFile('D:\Input.svg');
bmp.Params.JPEG_Quality := 90;
bmp.SaveToFile('D:\Output.jpg');
finally
bmp.Free();
end;
end;
See Also
◼LoadFromStream◼LoadFromBuffer◼Filename◼WicFastLoading◼IO