PNG文件验证

编程入门 行业动态 更新时间:2024-10-25 07:23:25
本文介绍了PNG文件验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个Flash网页应用程序,它会显示用户提交的PNG文件。文件上传到通过一些API服务器显示之前。我想,以确保没有坏的文件投放到Flash中,这里的坏是完全不确定的。有没有一种方法来验证PNG文件对PNG规范(这将赶上损坏的文件)?或者在处理不受信任的图像文件,任何最好的初步实践?我只需要处理PNG,所以JPG,GIF等的支持是必要的。语言大多没有关系,但我想preFER Python的解决方案。这是一个Unix网络服务器。

I have a Flash web app which displays user submitted PNG files. Files are uploaded to the server via some API prior to being displayed. I'd like to make sure no "bad" files are served to Flash, where "bad" is entirely unspecific. Is there a way to validate PNG files against the PNG specs (this would catch corrupted files)? Or any best pratice on dealing with untrusted image files? I only need to handle PNG, so JPG, GIF etc. support is necessary. Language mostly does not matter, though I'd prefer Python solutions. This is on a Unix webserver.

谢谢,西门

推荐答案

我会建议你使用Python和PIL(Python图像库这样做):

I would suggest you use Python and PIL (Python Imaging Library to do this):

from PIL import Image v_image = Image.open(file) v_image.verify()

捕获任何异常......

Catch any exceptions...

更多推荐

PNG文件验证

本文发布于:2023-07-27 00:21:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1219204.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件   PNG

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!