문제

Is there any way to determine if a JPEG file is corrupt after reading it via the FileReader API in JavaScript?

I'm thinking about something like what "libjpeg" does. It provides warning messages if something is wrong with the JPEG file.

도움이 되었습니까?

해결책

There are some libraries which do JPEG decoding in Pure JavaScript.

E.g. https://github.com/notmasteryet/jpgjs (there are others)

You can simply decode the FileReader fed data in your JavaScript code and see if the output is sane.

Depending of the degree of corruption, what cases you want to trap, it should be possible on client-side.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top