GNOME Bugzilla – Bug 548767
Add AI files (Adobe Illustrator) to "All Documents"
Last modified: 2017-09-28 04:01:52 UTC
Would be nice for .AI files to be included in the "All Documents" category of the open dialog. Since Illustrator 9 (or earlier), AI files are just PDF and evince displays them just fine if you drag the selector to "All Files" or specify on the command line.
Created attachment 118802 [details] [review] Adds 'application/illustrator' to PDF mimetypes Thought I'd take a shot at it. This tiny patch (to SVN) seems to work, except for this: When opening a .AI file that is *not* PDF and will not load (Postscript error), a blank page is never rendered as it is in 2.22.2 - evince says "loading..." indefinitely. Maybe I built the PS backend incorrectly? I'm no C programmer - so feel free to chew me out if this the wrong way to go about it :)
Do you have an AI file to test this? thanks.
Created attachment 190296 [details] Illustrator file - version CS3 (13)
Created attachment 190297 [details] Illustrator file - version 8
Review of attachment 118802 [details] [review]: Revisiting old bugs. This patch is wrong since a .ai file can be either a ps or a pdf... But if I run file -i test.ai to both tests I get correct mimetypes (meaning, ps and pdf mimetypes)
I can try again if you could point me in the right direction. It will be the weekend before I can bring my build environment up-to-date. I'm not sure where to look, since as you mention old .AI files can be Postscript while newer versions are simply PDF.
I am not sure... Evince already opens both test files. The problem is that you won't get the AI Documents neither Nautilus will let you choose evince to open an AI file... so there are two different things... the file mime-type gets detected... Actually evince open the files since there are two ways of getting the mime-type.. A fast way, which usually just checks the extension, and a non-fast way, which usually scans the file. So the .ai files will get application/illustrator if we get the mime-type with the fast way, and application/pdf or application/ps if we get the mime-type with the non-fast way. The only way I can think of doing this is by adding a new Ilustrator backend that detects the good mime-type and handles the rendering to the correct backend (ps or pdf)... or if we ever get a pspdf backend, we could add ai support to it.
ah, I forgot, the problem with nautilus is fixed by adding application/illustration to the .desktop file of evince I guess
Yeah - I think I have another patch for that on another bug. IIRC it needs work too.
(In reply to comment #7) > [...] > Actually evince open the files since there are two ways of getting the > mime-type.. A fast way, which usually just checks the extension, and a non-fast > way, which usually scans the file. So the .ai files will get > application/illustrator if we get the mime-type with the fast way, and > application/pdf or application/ps if we get the mime-type with the non-fast > way. The only way I can think of doing this is by adding a new Ilustrator > backend that detects the good mime-type and handles the rendering to the > correct backend (ps or pdf)... or if we ever get a pspdf backend, we could add > ai support to it. The non-fast way is very fast. It just look a few byes (magic number). According to http://en.wikipedia.org/wiki/Magic_number_%28programming%29#Magic_numbers_in_files * PostScript files and programs start with "%!" (25 21). * PDF files start with "%PDF" (hex 25 50 44 46).
It turns out there is a library (libmagic) which is BSD. I do not think it worth to add a dependency for just 2 files. However, the it might worth to take a look at that code. https://github.com/glensc/file
germán, there is already support for that in glib ;) the method for getting the mimetype has a boolean fast argument.
Created attachment 247083 [details] [review] Adds application/illustrator to "All Documents" This works (opens both test cases attached here), yet prints out some ugly warnings when opening a Postscript AI file. Example output: Syntax Warning: May not be a PDF file (continuing anyway) Syntax Error: Couldn't find trailer dictionary Syntax Error: Couldn't read xref table Somehow I think I'm doing this the wrong way.
Actually that last patch is no good at all - sorry. Correcting the ps backend to 'application/illustrator' (instead of "image/illustrator") just introduces segfaults. So - it's safe to say I have no idea what I'm doing ;)
Review of attachment 247083 [details] [review]: This patch does not work. Unfortunately... mimetype based just on .ai extension is not usable since old .ai files are ps while newones are .pdf
*** This bug has been marked as a duplicate of bug 311990 ***