加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

检测bash脚本中损坏的图像[已关闭]

发布时间:2020-12-16 01:29:45 所属栏目:安全 来源:网络整理
导读:我有一个来自网络摄像头流的2000张图像(延时视频),我需要删除所有不完整的在将它们传递给编辑他们的最终视频的php-gd脚本之前损坏的映像. 是否可以使用imagemagick或其他工具检测损坏的文件?如果我尝试用feh打开损坏的图像,它会显示libpng错误:在控制台中
我有一个来自网络摄像头流的2000张图像(延时视频),我需要删除所有不完整的&在将它们传递给编辑他们的最终视频的php-gd脚本之前损坏的映像.

是否可以使用imagemagick或其他工具检测损坏的文件?如果我尝试用feh打开损坏的图像,它会显示libpng错误:在控制台中读取错误

提前致谢!

更新:在我的情况下,似乎建议的识别方法接受坏的图像.这是一个被破坏的一个http://imgur.com/YcB9n的例子

尝试ImageMagick的识别命令.从手册页:

Identify 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()

从documentation:

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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读