Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #19414
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <chris@rebertia.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.005 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'python"': 0.07; 'python': 0.08; 'extension.': 0.09; 'url:github': 0.09; '25,': 0.12; 'am,': 0.12; 'library': 0.13; 'cc:addr:python-list': 0.15; '"file"': 0.16; 'bindings': 0.16; 'subject:mime': 0.16; 'wrote:': 0.16; 'wed,': 0.17; 'jan': 0.19; 'cheers,': 0.20; 'cc:no real name:2**0': 0.21; 'header:In-Reply-To:1': 0.22; 'cc:2**0': 0.25; 'module': 0.26; 'function': 0.27; 'received:209.85.220': 0.27; 'message-id:@mail.gmail.com': 0.28; 'cc:addr:python.org': 0.29; 'standalone': 0.30; 'chris': 0.30; '(as': 0.30; 'equivalent': 0.30; 'actually': 0.32; 'list': 0.32; 'there': 0.33; 'file.': 0.34; 'directory.': 0.34; 'external': 0.35; 'file': 0.35; 'google': 0.36; 'but': 0.37; "there's": 0.37; 'received:google.com': 0.37; 'received:209.85': 0.38; 'url:org': 0.39; 'received:209': 0.39; 'subject:: ': 0.39; 'type': 0.60; 'mime': 0.67; 'sender:addr:chris': 0.84; 'examining': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc :x-gm-message-state:content-type; bh=fX+RZZ6BxKy7RHov8ShM82a85m23YQR34t7Mv0b5I98=; b=Pk09hZO6ZNE5MMgMvjcRrZ3nvXuosDB0Pbh3or6EhbJg5FFTxqIrl7XmaZYix46tkR tIZ5sJGwqArwGudZDI0tr7m0Mvv8Amd2AfWCe/QccA5bjeNqxZcrGsa0LTFzn3/thSp2 TtEfe02xkU+A2tl9iawvVywKCSyjJ1ennIwq0= |
| MIME-Version | 1.0 |
| Sender | chris@rebertia.com |
| In-Reply-To | <20120125180432.76079215@bigfoot.com> |
| References | <20120125180432.76079215@bigfoot.com> |
| Date | Wed, 25 Jan 2012 09:40:47 -0800 |
| X-Google-Sender-Auth | aYsp2qRaWs_88ScUisecqOeSSbQ |
| Subject | Re: Find the mime type of a file. |
| From | Chris Rebert <clp2@rebertia.com> |
| To | Olive <diolu@bigfoot.com> |
| X-Gm-Message-State | ALoCoQljgnYp4L8GQOlXiQuq7BBqikD7tpzpRTxo2NCDjhy2xE5hXSwBeOJkVcFTBD1oiFZCSUqS |
| Content-Type | text/plain; charset=UTF-8 |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.5082.1327513254.27778.python-list@python.org> (permalink) |
| Lines | 18 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1327513254 news.xs4all.nl 6895 [2001:888:2000:d::a6]:37007 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:19414 |
Show key headers only | View raw
On Wed, Jan 25, 2012 at 9:04 AM, Olive <diolu@bigfoot.com> wrote: > I want to have a list of all the images in a directory. To do so I want > to have a function that find the mime type of a file. I have found > mimetypes.guess_type but it only works by examining the extension. In > GNU/Linux the "file" utility do much better by actually looking at the > file. Is there an equivalent function in python (as a last resort I can > always use the external file utility). There's 3rd-party Python bindings for the library that underlies the `file` command: https://github.com/ahupp/python-magic And there's an unrelated pure(?) Python standalone module from A-A-P: http://www.a-a-p.org/exec/ref-filetype.html Tip: google "file type detection python" Cheers, Chris
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Find the mime type of a file. Olive <diolu@bigfoot.com> - 2012-01-25 18:04 +0100 Re: Find the mime type of a file. Chris Rebert <clp2@rebertia.com> - 2012-01-25 09:40 -0800 Re: Find the mime type of a file. Jon Clements <joncle@googlemail.com> - 2012-01-25 16:12 -0800
csiph-web