How can I test for type of image
Hi there, I would like to test of what type an image is. How can I do that? I think I saw some code once but can not find it anymor. Thanks for your tips Robert
The refference for Python 1.5.2 mentions imghdr in section 14.9 which looks like it can do what you want. It can identify the most common file formats, but also include hook for extension. I have never tried using it, but remembered it when I saw you post. On Fri, Jun 29, 2001 at 01:37:38PM +0200, Robert Rottermann wrote:
Hi there, I would like to test of what type an image is. How can I do that? I think I saw some code once but can not find it anymor.
Thanks for your tips Robert
-- Martin Skøtt martin@xenux.dk Xenux Aps - The Linux People
Have you looked in the Image standard product? I did and found this: lib/python/OFS/content_types.py Not that I understand it, but it should be a good start for you I hope Peter ----- Original Message ----- From: "Robert Rottermann" <robert@redcor.ch> To: <zope@zope.org> Sent: Friday, June 29, 2001 1:37 PM Subject: [Zope] How can I test for type of image Hi there, I would like to test of what type an image is. How can I do that? I think I saw some code once but can not find it anymor. Thanks for your tips Robert
Robert Rottermann wrote:
Hi there, I would like to test of what type an image is. How can I do that? I think I saw some code once but can not find it anymor.
Thanks for your tips Robert
If it is an Image or File object in zope then: image.content_type will give it to you. If you are looking to check the type of a file uploaded from a form, then: file.headers['content-type'] hth, -- | Casey Duncan | Kaivo, Inc. | cduncan@kaivo.com `------------------>
participants (4)
-
Casey Duncan -
Martin Sk?tt -
Peter Bengtsson -
Robert Rottermann