[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: unable to open jpg file
From: |
James Cloos |
Subject: |
Re: unable to open jpg file |
Date: |
Mon, 14 Jan 2008 22:36:38 +0000 |
User-agent: |
Gnus/5.110007 (No Gnus v0.7) Emacs/23.0.60 (gnu/linux) |
File(1)'s magic file says this, for detecting jpegs:
,----[ excerpt from /usr/share/misc/file/magic ]
| # JPEG images
| # SunOS 5.5.1 had
| #
| # 0 string \377\330\377\340 JPEG file
| # 0 string \377\330\377\356 JPG file
| #
| # both of which turn into "JPEG image data" here.
| #
| 0 beshort 0xffd8 JPEG image data
| >6 string JFIF \b, JFIF standard
`----
So rather than searching for JFIF or EXIF emacs should test the first
two or four octets for the real magic cookie.
Magic.mime(4), used to determine the MIME type of a file, also only
tests the first two octets for 0xff and 0xd8. It should be enough,
then, for Emacs to test only those two octets as well.
Incidently, file(1) is under a 2-clause BSD-style license; incorporating
the magic.mime file and using that to determine how to open files might
make for a more robust -- or at least well-tested -- system.
-JimC
--
James Cloos <address@hidden> OpenPGP: 1024D/ED7DAEA6
- unable to open jpg file, xah lee, 2008/01/12
- Re: unable to open jpg file, Richard Stallman, 2008/01/13
- Re: unable to open jpg file, YAMAMOTO Mitsuharu, 2008/01/13
- Re: unable to open jpg file, xah lee, 2008/01/13
- Re: unable to open jpg file, YAMAMOTO Mitsuharu, 2008/01/13
- Re: unable to open jpg file, Jason Rumney, 2008/01/14
- Re: unable to open jpg file, xah lee, 2008/01/14
- Re: unable to open jpg file,
James Cloos <=
- Re: unable to open jpg file, Tom Tromey, 2008/01/15
- Re: unable to open jpg file, Richard Stallman, 2008/01/14
- Re: unable to open jpg file, Jason Rumney, 2008/01/14