Delphi - JPEG error #53

后端 未结 5 1338
你的背包
你的背包 2020-12-19 06:08

TImage.Picture.LoadFromFile(\'File.jpg\');

but i got JPEG error #53 ! what is the reason for this error?

相关标签:
5条回答
  • 2020-12-19 06:23

    Please try following to solve 'JPEG error #53' if its occur at this statement TImage.Picture.LoadFromFile('File.jpg')

    TImage.Picture.Bitmap.LoadFromFile('File.jpg');
    

    Note that File File.jpg should be exist at provided location.

    0 讨论(0)
  • 2020-12-19 06:28

    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;
    
    0 讨论(0)
  • 2020-12-19 06:31

    I also had the #53 error. It turned out that the error only occurred after I had erroneously saved a bitmap with the *.jpg extension. The obvious solution was to turn that bitmap into a jpeg and save it then :-).

    0 讨论(0)
  • 2020-12-19 06:35

    Does it occur to a single jpeg image or with all jpegs you try?

    JPEG error #53 error will come due to Insufficient memory.

    If file is corrupted, this error may occur.

    So opening this image in paint or photoshop and re-saving it in jpeg can solve the problem.

    0 讨论(0)
  • 2020-12-19 06:43

    my problem solved by using TAdvPicture componenet.

    0 讨论(0)
提交回复
热议问题