问题描述
是否有一种有效的方法来检测jpeg文件是否已损坏?
Is there an efficient way of detecting if a jpeg file is corrupted?
背景信息:
解决方案需要在php脚本中运行
jpeg文件在磁盘上
不能进行手动检查(用户上传的数据)
Background info:
solutions needs to work from within a php script
the jpeg files are on disk
manual checking is no option (user uploaded data)
我知道imagecreatefromjpeg(string $filename);
可以做到.但是这样做很慢.
I know that imagecreatefromjpeg(string $filename);
can do it. But it is quite slow at doing so.
有人知道更快/更有效的解决方案吗?
Does anybody know a faster/more efficient solutions?
推荐答案
在命令行中,您可以使用jpeginfo来确定jpeg文件是否正常.
From the command line you can use jpeginfo to find out if a jpeg file is OK or not.
test.jpeg 260 x 264 24位JFIF N 15332 [确定]
test.jpeg 260 x 264 24bit JFIF N 15332 [OK]
从php调用jpeginfo应该很简单.
It should be trivial to call jpeginfo from php.
这篇关于有效检测损坏的jpeg文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!