我有一个来自网络摄像头流的2000张图像(延时视频),我需要删除所有不完整的&在将它们传递给编辑他们的最终视频的PHP-gd脚本之前损坏的映像.
是否可以使用imagemagick或其他工具检测损坏的文件?如果我尝试用feh打开损坏的图像,它会显示libpng错误:在控制台中读取错误
提前致谢!
更新:在我的情况下,似乎建议的识别方法接受坏的图像.这是一个被破坏的一个http://imgur.com/YcB9n的例子
尝试ImageMagick的识别命令.从手册页:
原文链接:https://www.f2er.com/bash/383702.htmlIdentify describes the format and
characteristics of one or more image
files. It will also report if an image
is incomplete or corrupt.
例:
$identify foo.png identify: NotAPNGImageFile (foo.png). $echo $? 1
另一种方法是使用PIL(Python Imaging Library):
from PIL import Image im = Image.open("foo.png") im.verify()
im.verify()
Attempts to determine if the file is broken,without actually decoding the image data. If this method finds any problems,it raises suitable exceptions. This method only works on a newly opened image; if the image has already been loaded,the result is undefined. Also,if you need to load the image after using this method,you must reopen the image file.