php - 如何检测图像是 PNG 还是 APNG 格式?

标签 php python ruby perl apng

<分区>

Possible Duplicate:
Can I programatically determine if a PNG is animated?

APNG 向后兼容 PNG。我在十六进制编辑器中打开了 apng 和 png 文件,前几个字节看起来相同。因此,如果用户上传这两种格式中的任何一种,我如何检测真正的格式是什么?我在一些阻止 apng 的网站上看到过这样做。

我猜 ImageMagick 库使这很容易,但如果我在不使用图像处理库(用于学习目的)的情况下进行检测怎么办?我可以查找告诉我文件是否为 apng 的特定字节吗?

欢迎使用任何语言的解决方案。

最佳答案

来自 http://en.wikipedia.org/wiki/Apng :

Among users and maintainers of the PNG and MNG formats, APNG was not well received. In particular, PNG was conceived to be a single-image format [2]. APNG hides the subsequent frames in PNG ancillary chunks in such a way that APNG-unaware applications would ignore them, but there are otherwise no changes to the format to allow software to distinguish between animated and non-animated images. [italics mine]

[2] "PNG (Portable Network Graphics) Specification, Version 1.1#8.4. Multiple-image extension"

关于php - 如何检测图像是 PNG 还是 APNG 格式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4705674/

相关文章:

python - 在 Python 中按索引从列表中删除元素的简洁方法

arrays - 在 Ruby 中将数组转换为索引哈希

Ruby OptionParser 空开关 "-"行为

php - 修剪面包屑

php - 响应成功时更新我的​​表总是返回空白

php - 验证不适用于注册表单

php - Composer创建项目错误

python - 布局在执行 pyqt 时不起作用

ruby-on-rails - 如何在 ruby​​ on rails 中显示父表列名?

python - URL : Binary Blob, Unicode 或编码的 Unicode 字符串?