From: James Cloos <cloos@jhcloos.com>
To: emacs-pretest-bug@gnu.org
Cc: xah lee <xah@xahlee.org>,
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>,
Jason Rumney <jasonr@gnu.org>
Subject: Re: unable to open jpg file
Date: Mon, 14 Jan 2008 22:36:38 +0000 [thread overview]
Message-ID: <m3hchgvxu1.fsf@lugabout.jhcloos.org> (raw)
In-Reply-To: <478B618B.6040404@gnu.org> (Jason Rumney's message of "Mon, 14 Jan 2008 13:20:11 +0000")
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 <cloos@jhcloos.com> OpenPGP: 1024D/ED7DAEA6
next prev parent reply other threads:[~2008-01-14 22:36 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-13 2:58 unable to open jpg file xah lee
2008-01-14 2:01 ` Richard Stallman
2008-01-14 3:29 ` YAMAMOTO Mitsuharu
2008-01-14 3:55 ` xah lee
2008-01-14 4:27 ` YAMAMOTO Mitsuharu
2008-01-14 13:20 ` Jason Rumney
2008-01-14 13:42 ` xah lee
2008-01-14 22:36 ` James Cloos [this message]
2008-01-15 16:08 ` Tom Tromey
2008-01-14 17:26 ` Richard Stallman
2008-01-14 23:15 ` Jason Rumney
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m3hchgvxu1.fsf@lugabout.jhcloos.org \
--to=cloos@jhcloos.com \
--cc=emacs-pretest-bug@gnu.org \
--cc=jasonr@gnu.org \
--cc=mituharu@math.s.chiba-u.ac.jp \
--cc=xah@xahlee.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.