Bug 2686

Summary: EPS sniffed as PS
Product: shared-mime-info Reporter: Vincent Noel <vnoel>
Component: freedesktop.org.xmlAssignee: Jonathan Blandford <jrb>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: high CC: seb128, shurik179
Version: unspecified   
Hardware: x86 (IA32)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: Override.xml (for correct eps sniffing)
subclass image/x-eps as application/postscript
patch to xdgmime which fixes the issue

Description Vincent Noel 2005-03-09 10:49:34 UTC
All the EPS files ("Encapsulated PostScript image") I create using IDL are
recognized as postscript ("PostScript document" or application/postscript). It
means I cannot open them by double-clicking in nautilus.

The header of the EPS files looks like this :

%!PS-Adobe-3.0 EPSF-3.0
%%BoundingBox: 0 0 1020 340
%%Title: Graphics produced by IDL
%%Creator: IDL Version 5.6 (linux x86 m32)
%%CreationDate: Tue Mar  8 17:24:29 2005
%%DocumentData: Clean7bit
%%Requirements: color
%%LanguageLevel: 1
%%PageOrder: Ascend
%%Pages: (atend)
%%DocumentNeededResources: (atend)
%%EndComments
%%BeginPreview: 128 128 8 328
Comment 1 Christopher Maes 2005-04-04 14:40:06 UTC
Created attachment 2333 [details]
Override.xml (for correct eps sniffing)
Comment 2 Christopher Maes 2005-04-04 14:40:47 UTC
The mime-type image/x-eps needs to have a higher magic priority than
application/postscript (because it is more specific). 

Currently both have a magic-priority of 50. I fixed this problem by simply
increasing the priority of image/x-eps to 51. (See attached override.xml
file)

This allows eps files to be associated with an application in nautilus 
(and then be opened by simply double clicking on them).

Cheers,
Chris
Comment 3 Vincent Noel 2005-04-05 07:03:47 UTC
Can you please explain where is the file I need to modify to make this work ?
I looked in /usr/share/mime/image/x-eps.xml but it says "created automatically,
do not edit, bla bla".
Comment 4 Christophe Fergeau 2005-04-05 07:07:35 UTC
You need to put it in the /usr/share/mime/package and to run
update-mime-database /usr/share/mime 
Or maybe you need to modifiy freedesktop.xml.in to use the content of this file
instead of the current definition for eps file (if there's any).
Comment 5 Vincent Noel 2005-04-05 07:12:14 UTC
It works. You are my hero.
Comment 6 Christopher Maes 2005-04-07 10:27:25 UTC
Since eps is a subset of postscript, rather than changing the priority, a
better fix would be to make image/x-eps a subclass of application/postscript:

<mime-type type="image/x-eps">
    <sub-class-of type="application/postscript"/>
    <comment>Encapsulated PostScript image</comment>
    <comment xml:lang="az">Encapsulated PostScript r??smi</comment>
    <comment xml:lang="cs">Obr??zek v zapouzd??en??m Postscriptu</comment>
    <comment xml:lang="cy">Delwedd PostScript wedi ei chrisialu</comment>
    <comment xml:lang="de">EPS-Bild</comment>
    <comment xml:lang="el">???????????? Encapsulated PostScript</comment>
    <comment xml:lang="fi">kapsuloitu PostScript-kuva</comment>
    <comment xml:lang="fr">image encapsul?? PostScript</comment>
    <comment xml:lang="hu">Encapsulated PostScript-k??p</comment>
    <comment xml:lang="ko">???????????? ????????????????????? ?????????</comment
>
    <comment xml:lang="nl">Ingekapselde Postscript afbeelding</comment>
    <comment xml:lang="nn">Encapsulated PostScript-bilete</comment>
    <comment xml:lang="sr">?????????????????? ???????????????????? ?????????? (E
PS)</comment>
    <comment xml:lang="sv">Inkapslad PostScript-bild</comment>
    <magic priority="50">
      <match value="%!" type="string" offset="0">
        <match value="EPS" type="string" offset="15"/>
      </match>
      <match value="\004%!" type="string" offset="0">
        <match value="EPS" type="string" offset="16"/>
      </match>
  </magic>
    <glob pattern="*.eps"/>
    <glob pattern="*.epsi"/>
    <glob pattern="*.epsf"/>
  </mime-type>
</mime-info>

This would allow eps files to be opened with the default postscript viewer. 
I've attached my Override.xml file (in case anyone wants to fix this
themselves). Simply place it in /usr/share/mime/packages and 

sudo update-mime-database /usr/share/mime
Comment 7 Christopher Maes 2005-04-07 10:29:30 UTC
Created attachment 2344 [details]
subclass image/x-eps as application/postscript
Comment 8 Stewart Jeacocke 2005-04-11 10:50:46 UTC
Actually I think you need to make both changes.

Declaring eps as a subclass of ps is good because it means that
you inherit all the application associations given to generic
postscript. Raising the priority of the magic pattern for eps is needed
because otherwise when you go to the nautilus properties window for a
valid eps file it will be listed as type application/postscript (not
image/x-eps).

This bug has also been reported in Debian,
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=259652
Comment 9 Christophe Fergeau 2005-04-16 05:38:13 UTC
I marked eps files as a subclass of postscript files (Christopher, I trust you
when you say they are valid postcript files, I have no idea on the matter for my
part ;).
I haven't tested if this solves the magic sniffing issue, but I don't think t's
worth raising the magic, the magic pattern for .eps files match a subset of .ps
files and has the same priority, so imo the file should be sniffed as an eps
file and not a ps one. I have to check what the code does, and bring the issue
on xdg mailing list if it's not behaving as I expect.
Comment 10 Christophe Fergeau 2005-04-16 16:12:04 UTC
Created attachment 2439 [details] [review]
patch to xdgmime which fixes the issue

I committed this patch to xdgmime, together with the subclass-of patch this
should fix the issue.
Comment 11 Christophe Fergeau 2005-04-16 16:12:35 UTC
Marking as fixed.
Comment 12 Stewart Jeacocke 2005-05-01 03:41:13 UTC
*** Bug 3166 has been marked as a duplicate of this bug. ***

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.