我有一个 Flash 网络应用程序,可以显示用户提交的 PNG 文件.文件在显示之前通过一些 API 上传到服务器.我想确保没有坏"文件提供给 Flash,其中坏"完全不具体.有没有办法根据 PNG 规范验证 PNG 文件(这会捕获损坏的文件)?或者任何处理不受信任的图像文件的最佳实践?我只需要处理PNG,所以需要JPG、GIF等支持.语言大多无关紧要,但我更喜欢 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 Imaging Library 来做到这一点):
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()捕捉任何异常...
更多推荐
PNG 文件验证
发布评论