TImage.Picture.LoadFromFile(\'File.jpg\');
but i got JPEG error #53 ! what is the reason for this error?
This usually comes when the Jpeg image is downloaded from Internet and the download is not 100% complete. It can happen even with TImage. Unfortunately Jpeg do not have a checksum to check against.
The only think you can do is whenever this error is thrown to catch it and display more responsive message like "The image is corrupted.".
Since this raises the error:
procedure JpegError(cinfo: j_common_ptr); {$IFDEF LINUX} cdecl; export; {$ENDIF}
begin
raise EJPEG.CreateFmt(sJPEGError,[cinfo^.err^.msg_code]);
end;
where
sJPEGError = 'JPEG error #%d';
you can try to catch EJPEG error and check for #53 within the message.
Since EJPEG inherits from EInvalidGraphic you can simply catch it with
catch
on E: EInvalidGraphic do
begin
ShowMessage('Image file is corrupted.')
end;
end;