From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: using libmagic in Emacs? Date: Sun, 23 Aug 2009 02:36:22 +0300 Organization: JURTA Message-ID: <87y6pb8lqh.fsf@mail.jurta.org> References: <87ocqco7fi.fsf@mail.jurta.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1250987922 6038 80.91.229.12 (23 Aug 2009 00:38:42 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 23 Aug 2009 00:38:42 +0000 (UTC) Cc: monnier@IRO.UMontreal.CA, joakim@verona.se, emacs-devel@gnu.org To: rms@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Aug 23 02:38:35 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Mf16Q-0000ty-BP for ged-emacs-devel@m.gmane.org; Sun, 23 Aug 2009 02:38:34 +0200 Original-Received: from localhost ([127.0.0.1]:49451 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mf16P-00041U-Jx for ged-emacs-devel@m.gmane.org; Sat, 22 Aug 2009 20:38:33 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mf16K-00040K-Ok for emacs-devel@gnu.org; Sat, 22 Aug 2009 20:38:28 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mf16F-0003w1-L2 for emacs-devel@gnu.org; Sat, 22 Aug 2009 20:38:27 -0400 Original-Received: from [199.232.76.173] (port=57650 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mf16F-0003vy-Hn for emacs-devel@gnu.org; Sat, 22 Aug 2009 20:38:23 -0400 Original-Received: from smtp-out1.starman.ee ([85.253.0.3]:45324 helo=mx1.starman.ee) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Mf16B-0006vZ-Ou; Sat, 22 Aug 2009 20:38:20 -0400 X-Virus-Scanned: by Amavisd-New at mx1.starman.ee Original-Received: from mail.starman.ee (82.131.29.189.cable.starman.ee [82.131.29.189]) by mx1.starman.ee (Postfix) with ESMTP id 5523A3F4104; Sun, 23 Aug 2009 03:38:11 +0300 (EEST) In-Reply-To: (Richard Stallman's message of "Wed, 19 Aug 2009 23:42:07 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (x86_64-pc-linux-gnu) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:114522 Archived-At: > >> For instance, in "image.el" there is functionality to look at > >> magic numbers in image files. > > image.el doesn't recognize some rare JPEG formats, so libmagic > will be useful here. > > Extending image.el mightbe a lot easier than other solutions. The problem is that `image-jpeg-p' in image.el refuses to accept non-JFIF JPEG image files whereas Emacs can correctly display them when tests in `image-jpeg-p' are ignored. Using libmagic means looking only for 2 bytes 0xffd8 (a magic number of JPEG files) as described by the magic number file: 0 beshort 0xffd8 JPEG image data It seems this is enough to determine JPEG files. But I'm not confident about removing additional tests from `image-jpeg-p'. We could keep the current rules in image.el as a fall-back when libmagic is not available. -- Juri Linkov http://www.jurta.org/emacs/