确定文件是否是有效的图像文件 [英] Determining if file is valid image file

查看:59
本文介绍了确定文件是否是有效的图像文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

除了安装PIL之外,还有一个简单的东西。仅使用Python的方式

来确定文件是否是有效的图像文件?


如果我能至少识别出有效的图像文件,我会很高兴对于GIF,

jpeg和png。指向现有模块或示例的指针将是

赞赏。


我不想使用PIL的原因是我想要捆绑

我的应用程序中的这样一个功能/模块。

$ b $bAndré

Other than installing PIL, is there a "simple" way using Python only
to determine if a file is a valid image file?

I''d be happy if I could at least identify valid images files for gif,
jpeg and png. Pointers to existing modules or examples would be
appreciated.

The reason why I''d prefer not using PIL is that I''d like to bundle
such a function/module in my app.

André

推荐答案

8月2日上午11:14,André< andre.robe ... @ gmail.comwrote:
On Aug 2, 11:14 am, André <andre.robe...@gmail.comwrote:

除了安装PIL之外,是有一个简单的仅使用Python的方式

来确定文件是否是有效的图像文件?


如果我能至少识别出有效的图像文件,我会很高兴对于GIF,

jpeg和png。指向现有模块或示例的指针将是

赞赏。


我不想使用PIL的原因是我想要捆绑

我的应用程序中的这样一个功能/模块。

$ b $bAndré
Other than installing PIL, is there a "simple" way using Python only
to determine if a file is a valid image file?

I''d be happy if I could at least identify valid images files for gif,
jpeg and png. Pointers to existing modules or examples would be
appreciated.

The reason why I''d prefer not using PIL is that I''d like to bundle
such a function/module in my app.

André



我应该添加:我很有兴趣验证文件*内容*

- 不是文件名:-)

I should have added: I''m interesting in validating the file *content*
- not the filename :-)


André写道:
André wrote:

8月2日上午11点14分,André< andre.robe ... @ gmail.comwrote:
On Aug 2, 11:14 am, André <andre.robe...@gmail.comwrote:

>除了安装PIL之外,还有一个简单的东西吗?仅使用Python确定文件是否为有效图像文件的方式?
如果我至少可以识别gif的有效图像文件,我会很高兴,
jpeg和png。对现有模块或示例的指示将受到赞赏。

我不想使用PIL的原因是我想要捆绑
这样的功能/我的应用程序中的模块。

André
>Other than installing PIL, is there a "simple" way using Python only
to determine if a file is a valid image file?

I''d be happy if I could at least identify valid images files for gif,
jpeg and png. Pointers to existing modules or examples would be
appreciated.

The reason why I''d prefer not using PIL is that I''d like to bundle
such a function/module in my app.

André



我应该补充:我很有兴趣验证文件*内容*

- 不是文件名:-)


I should have added: I''m interesting in validating the file *content*
- not the filename :-)



在您的应用程序中捆绑PIL有什么问题?


-Larry

And what''s wrong with bundling PIL in your application?

-Larry


Andrénapisa3(a):
André napisa3(a):

>除了安装PIL之外,还有一个简单的东西。仅使用Python确定文件是否为有效图像文件的方式?
如果我至少可以识别gif的有效图像文件,我会很高兴,
jpeg和png。对现有模块或示例的指示将受到赞赏。

我不想使用PIL的原因是我想要捆绑
这样的功能/我的应用程序中的模块。

André
>Other than installing PIL, is there a "simple" way using Python only
to determine if a file is a valid image file?

I''d be happy if I could at least identify valid images files for gif,
jpeg and png. Pointers to existing modules or examples would be
appreciated.

The reason why I''d prefer not using PIL is that I''d like to bundle
such a function/module in my app.

André



我应该补充:我很有兴趣验证文件*内容*

- 不是文件名:-)


I should have added: I''m interesting in validating the file *content*
- not the filename :-)



模块imghdr是否足以满足您的需求?


- -

Jarek Zgoda

Skype:jzgoda | GTalk: zg***@jabber.aster.pl |声音:+48228430101

我们读过Knuth所以你不必这么做。 (蒂姆·彼得斯)

Is the module imghdr enough for your needs?

--
Jarek Zgoda
Skype: jzgoda | GTalk: zg***@jabber.aster.pl | voice: +48228430101

"We read Knuth so you don''t have to." (Tim Peters)


这篇关于确定文件是否是有效的图像文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆