[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.

James Cloos <address@hidden>         OpenPGP: 1024D/ED7DAEA6

reply via email to

[Prev in Thread] Current Thread [Next in Thread]